It's like the code below does nothing (I tested on a real device). I get the message "We haven't detected any subscribed users yet for this platform" from the OneSignal website when I added my app. I checked multiple times the different ids/api keys seem ok. No error in the console.
import {OneSignal} from 'ionic-native';
platform.ready().then(() => {
OneSignal.setLogLevel({
logLevel: 6,
visualLevel: 6
});
let notificationOpenedCallback = function(jsonData) {
console.log('didReceiveRemoteNotificationCallBack: ' + JSON.stringify(jsonData));
};
OneSignal.init('xxx-xxx-xxx-xxx-xxx', {
googleProjectNumber: 'xxx'
},
notificationOpenedCallback
);
OneSignal.enableInAppAlertNotification(true);
});
Cordova CLI: 6.3.1
Gulp version: CLI version 3.9.1
Gulp local:
Ionic CLI Version: 2.0.0-beta.37
Ionic App Lib Version: 2.0.0-beta.20
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Mac OS X El Capitan
Node Version: v4.4.7
Xcode version: Xcode 7.3.1 Build version 7D1014
cordova-plugin-camera 2.2.0 "Camera"
cordova-plugin-compat 1.0.0 "Compat"
cordova-plugin-console 1.0.3 "Console"
cordova-plugin-device 1.1.2 "Device"
cordova-plugin-file 4.2.0 "File"
cordova-plugin-file-transfer 1.5.1 "File Transfer"
cordova-plugin-splashscreen 3.2.2 "Splashscreen"
cordova-plugin-statusbar 2.1.3 "StatusBar"
cordova-plugin-whitelist 1.2.2 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"
onesignal-cordova-plugin 1.13.1 "OneSignal Push Notifications"
@Inoverse can you have a look at this if you have some time?
@root-io Which Ionic-Native version do you use?
ionic-native 1.3.16
Oh okay. I changed the init function in 1.3.10 and didn't updated the documentation. PR: 08fe04e
The init function no longer needs a callback. It's now an Observable. So you need to change your code:
import {OneSignal} from 'ionic-native';
platform.ready().then(() => {
OneSignal.setLogLevel({
logLevel: 6,
visualLevel: 6
});
OneSignal.init('xxx-xxx-xxx-xxx-xxx', {
googleProjectNumber: 'xxx'
})
.subscribe(jsonData => {
console.log('didReceiveRemoteNotificationCallBack: ' + JSON.stringify(jsonData));
};
OneSignal.enableInAppAlertNotification(true);
});
I've created a new PR to fix the documentation #467
Hope this helps you out!
Awesome, it works now, thank you!