Skip to content

Instantly share code, notes, and snippets.

@brunofrank
Created November 14, 2017 18:05
Show Gist options
  • Save brunofrank/049a6c0ed79e2c2209eb40939136e034 to your computer and use it in GitHub Desktop.
Save brunofrank/049a6c0ed79e2c2209eb40939136e034 to your computer and use it in GitHub Desktop.
setupOneSignal(){
this.oneSignal.startInit('ab4692d4...');
this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.Notification);
this.oneSignal.handleNotificationReceived().subscribe((jsonData) => {
if (jsonData.isAppInFocus){
let alert = this.alertCtrl.create({
title: notification.title,
message: notification.body,
buttons: ['OK']
});
alert.present();
}
});
this.oneSignal.iOSSettings({kOSSettingsKeyAutoPrompt: false, kOSSettingsKeyInAppLaunchURL: false});
this.oneSignal.endInit();
this.oneSignal.getIds().then((deviceID) => {
let _vendor = this.platform.is('android') ? 'android' : 'ios';
let deviceData = {player_id: deviceID.userId, token: deviceID.pushToken, vendor: _vendor}
this.sessionProvider.saveDeviceData(deviceData);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment