Hi All,
Having some trouble with OneSignal Ionic Native.
I’ve tried testing it on a real device using BrowserStack App live. Its registering a new user,
though not one that I can send notifications to.
I have a pod installed for OneSignal and I’ve added the required code in iOS to use the SDK as follows:
var iosSettings = {};
iosSettings["kOSSettingsKeyAutoPrompt"] = false; // will not prompt users when start app 1st time
iosSettings["kOSSettingsKeyInAppLaunchURL"] = false; // false opens safari with Launch URL
// OneSignal Code start:
// Enable to debug issues.
// window["plugins"].OneSignal.setLogLevel({logLevel: 4, visualLevel: 4});
try{
this.oneSignal.startInit('@@@@@@@@', '@@@@@@@');
this.oneSignal.registerForPushNotifications();
this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.InAppAlert);
this.oneSignal.handleNotificationReceived().subscribe(() => {
// do something when notification is received
console.log('Notification Received!');
});
this.oneSignal.handleNotificationOpened().subscribe(() => {
// do something when a notification is opened
});
this.oneSignal.endInit();
var iosSettings = {};
iosSettings["kOSSettingsKeyAutoPrompt"] = false; // will not prompt users when start app 1st time
iosSettings["kOSSettingsKeyInAppLaunchURL"] = false; // false opens safari with Launch URL
// OneSignal Code start:
// Enable to debug issues.
// window["plugins"].OneSignal.setLogLevel({logLevel: 4, visualLevel: 4});
var notificationOpenedCallback = function(jsonData) {
console.log('notificationOpenedCallback: ' + JSON.stringify(jsonData));
if (jsonData.notification.payload.additionalData != null) {
console.log("Here we access addtional data");
if (jsonData.notification.payload.additionalData.openURL != null) {
console.log("Here we access the openURL sent in the notification data");
}
}
};
window["plugins"].OneSignal
.startInit('@@@@@@@@@@@@@')
.iOSSettings(iosSettings) // only needed if added Optional OneSignal code for iOS above
.inFocusDisplaying(window["plugins"].OneSignal.OSInFocusDisplayOption.Notification)
.handleNotificationOpened(notificationOpenedCallback)
.endInit();
Any help would be greatly appreciated.
Thanks