Home:ALL Converter>integrating OneSignal into Ionic 3 causes problem on iOS device

integrating OneSignal into Ionic 3 causes problem on iOS device

Ask Time:2018-08-30T16:18:29         Author:wassim ayari

Json Formatter

I have an ionic application which works fine both on android and iOS, in simulator and in real devices. I have integrated the OneSignal API to add notifications to my application. On android everything works fine, but the problem shows up when running on an iOS device.

These are the steps I use to run the project on iOS: - Add the iOS platform with the command ionic cordova platform add ios - Build the ionic app source to generate the Xcode project with the command ionic cordova build ios --prod or ionic cordova build ios - Open generated project in Xcode - Assign the team to the project - Add push notification to project from the tab 'capabilities' - Add remote notification to background mode - Generate the .cer and .p12 certifications - Add them to The OneSignal project on the OneSignal dashboard - Run the project

After that when I build the app from Xcode to the iOS device (connected to my mac via a cable), the notification permission popup appears, I accept it and the notifications comes when I send them from the OneSignal dashboard. But when I try running the app again (with the iOS device not connected to the mac) it does not work, the splash screen keeps loading infinitely.

I noticed another thing that when building with --prod flag the app does not work neither when connected to the mac or not. But without that flag, it works only when running it from Xcode as I said before.

I am almost certain that's due to the OneSignal API since without it, everything works fine when connected to the mac or not.

OneSignal version: ^2.4.2

iOS version: 10.3.3

Ionic info:

Ionic:

   ionic (Ionic CLI)  : 4.0.6 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.1.9

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : ios 4.5.5

System:

   ios-deploy : 2.0.0
   NodeJS     : v8.10.0 (/usr/local/bin/node)
   npm        : 5.6.0
   OS         : macOS High Sierra
   Xcode      : Xcode 9.3 Build version 9E145

Environment:

   ANDROID_HOME : not set

Author:wassim ayari,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/52092281/integrating-onesignal-into-ionic-3-causes-problem-on-ios-device
yy