integrating OneSignal into Ionic 3 causes problem on iOS device - ios

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

Related

ionic ios build give error whe work on ios

I worked on ionic version 3 app I want to publish it to the apple store I build it successfully but when to submit it to review the app rejected because
We discovered one or more bugs in your app when reviewed on iPad
running iOS 13.7 on Wi-Fi.Your app launches and shows an unresponsive
white screen with no other content.
then I start a new ionic 3 project and I faced the same problem.
I tried to build using Cordova ios v6 and v5 but I have the same problem.
I build it using these commands
ionic cordova platform add ios
ionic cordova run ios --prod -l --external --emulator --consolelogs --target="C62C1D15-1BDF-433C-BD72-2D9957C5F0F7"
when I run it on iPhone emulator it works well but on iPad give me these issues
[app-scripts] [00:02:36] console.warn: Ionic Native: tried calling StatusBar.styleDefault, but Cordova is not available. Make sure to
[app-scripts] a) run in a real device or simulator and b) include cordova.js in your index.html
[app-scripts] [00:02:36] console.warn: Ionic Native: tried calling SplashScreen.hide, but Cordova is not available. Make sure to a)
[app-scripts] run in a real device or simulator and b) include cordova.js in your index.html
using
cordova v10.0.0
ionic cli v6.11.0
Plugins use the platform's native code. To execute that code, they rely on Cordova. The error message "Cordova is not available" is thrown when the plugin code is executed before cordova has loaded.
You should ensure that all plugin related code is executed only after they have been loaded. You can do this by subscribing to the platform ready event & executing plugin code only after that is fired. An example of this would be import { Platform } from 'ionic-angular';
#Component({...})
export MyApp {
constructor(public plt: Platform) {
this.plt.ready().then((readySource) => {
console.log('Platform ready from', readySource);
// Platform now ready, execute any required native code
});
}
}

Ionic 3 build with --minifyjs flag get stucks on first load of app only in iOS

I have an Ionic 3 app that runs well in Android and iOS without the --prod flag. Now I want to test the App in production mode in iOS and Android.
When I try to run it on Android everything works great! and a little bit faster and smoother. Now I try to run it on iOS which it doesn't work. It gets stuck on the first load of the App on the Splashscreen. At first I expect that there is something wrong in my plugins or versions compatibility of my plugins and to the version of the iOS device.
But I was wrong I try to run it without the --uglifyjs, --minifycss, -aot, --optimizejs and it works, the app didn't get stuck at the first booth or first load. All these flags are part of the --prod flag right? But you notice that I didn't include --minifyjs in the flag. Because when I try to run it on --minifyjs the problem occurs again when it got stucks on the first load of the app.
I have also reference to my old question: Ionic cordova run ios --prod gets stuck on splash screen loader but that wasn't the problem anymore. It only happens when I try to use the --minifyjs flag.
Here is my ionic info:
cli packages: (/usr/local/lib/node_modules)
#ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
#ionic/app-scripts : 3.2.0
Cordova Platforms : ios 4.5.5
Ionic Framework : ionic-angular 3.9.2
System:
ios-deploy : 1.9.2
Node : v8.9.3
npm : 5.5.1
OS : macOS High Sierra
Xcode : Xcode 10.0 Build version 10A255
Environment Variables:
ANDROID_HOME : not set
Misc:
backend : pro
So what can be the problem with that? I think it is more of a compiling issue of minifying js files by angular and ionic by reducing its size. I think it affects some of the js files that caused the problem.
Appreciate if someone could help. Thanks in advance.

ionic: missing entitlements for iOS project

I have developed ionic application with following environment. Now, I need to transfer the work to my colleague but he is unable to build fully functional app which includes capabilities such as 'Associated domains', 'Background Modes' and 'Push Notifications'.
cli packages: (/usr/local/lib/node_modules)
#ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
#ionic/app-scripts : 3.1.10
Cordova Platforms : android 7.1.0 ios 4.5.4
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 26.1.1
ios-deploy : 1.9.2
Node : v10.8.0
npm : 6.2.0
OS : macOS High Sierra
Xcode : Xcode 9.4.1 Build version 9F2000
Although he is able to build and archive the project, generated ipa has no entitlements listed(all of them are ON at capability selections) and Certificate says "Unknown" at the export dialog using Organizer.
We are using the same certificates, profiles and everything but the OS.
I am using macOS High Sierra with Xcode 9.4.1 and he is using macOS mojave and Xcode 10.1.
Our Android version of app can be build and run fine.
Does anyone have similar experience and know how to resolve this issue?
Thank you in advance.
We found this thread on apple developer forum and by downgrading Xcode, the build problem was resolved.
Old version of Xcode can be downloaded here.

Ionic 3 IOS App does not work for first launch, but works after force kill and launch

I am building an IOS app using IONIC.
When I first launch the App in simulator or real device, the app is stuck on splash screen. Platform ready event is never getting called and thus splashscreen is never hidden. But it works fine after I kill the app and launch again. No idea which direction should I look in. Here is my ionic info
#ionic/cli-utils : 2.0.0-rc.6
ionic (Ionic CLI) : 4.0.0-rc.6
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
#ionic/app-scripts : 3.1.9
Cordova Platforms : android 7.0.0 ios 4.5.4
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 26.1.1
ios-deploy : 1.9.2
NodeJS : v8.9.1
npm : 6.0.0
OS : macOS High Sierra
Xcode : Xcode 9.4 Build version 9F1027a
Environment Variables:
ANDROID_HOME : /Users/ashfaq/Library/Android/sdk/
please try this :
In xCode File > Workspace Settings > Build System : Legacy Build System
In Signing Team, be sur to use Team and provisioning Profile with developer capability (Debug) and not for production (Realse)

APP only works the first time on ios

im having a problem since I’m trying to test my app on iOS.
The first time I install my app on an emulator/device the app works correctly. But if I close my app, and open again the app don’t work anymore and get stuck on the white screen forever.
My ionic info is:
cli packages: (/usr/local/lib/node_modules)
#ionic/cli-utils : 1.14.0
ionic (Ionic CLI) : 3.14.0
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
#ionic/app-scripts : 3.0.1
Cordova Platforms : ios 4.5.2
Ionic Framework : ionic-angular 3.7.1
System:
Node : v8.7.0
npm : 5.4.2
OS : macOS Sierra
Xcode : Xcode 9.0 Build version 9A235
Misc:
backend : pro
I tried so many solutions, like remove and add de platforms, remove and add de plugin one by one. The app works on Android perfectly, but on iOS I have this problem.
Can someone help me?
We can debug ios application
ionic emulate ios -lc
Which runs app using simulator and outputs console logs and errors to terminal with live reloading.
There are three primary options.
Debug using Safari. This is good for debugging a hybrid app, but
cannot tell you output related to native plugins.
http://webdesign.tutsplus.com/articles/quick-tip-using-web-inspector-to-debug-mobile-safari--webdesign-8787
Open the project and build to device in Xcode. This shows the output of the entire device http://cordova.apache.org/docs/en/3.5.0/guide_platforms_ios_index.md.html#iOS%20Platform%20Guide
Debug with Ionic CLI. Using ionic run ios -l -c -s with the flags will use live reload and print the logs to the console. http://ionicframework.com/blog/live-reload-all-things-ionic-cli/
From: Debug Ionic app on IOS?

Resources