Ionic - OneSignal doesn't work on iOS 13.x - ios

I have a problem with my ionic 3 app and OneSignal.
The app working fine on Android version and iOS version 12.x, but in iOS 13.* nothing happends.
Viewing in the OneSignal Dashboard the device not registered. I also don't get the playerid in my app (calling getIds() method).
app.component.ts:
constructor(platform: Platform,
statusBar: StatusBar,
private oneSignal: OneSignal,
public api: ApirestProvider,
private alertCtrl: AlertController,
splashScreen: SplashScreen) {
platform.ready().then(() => {
statusBar.styleDefault();
splashScreen.hide();
this.handlerNotifications();
});
}
private handlerNotifications(){
this.oneSignal.startInit('xxxxxxxxxxxxxxxxxxxxxxxxxx', 'xxxxxxxxxxxxx');
this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.Notification);
this.oneSignal.handleNotificationOpened()
.subscribe(jsonData => {
let alert = this.alertCtrl.create({
title: jsonData.notification.payload.title,
subTitle: jsonData.notification.payload.body,
buttons: ['OK']
});
alert.present();
});
this.oneSignal.getIds().then(identity => {
console.log("Player ID:" + identity.userId);
this.api.player_id=identity.userId;
}).catch(err => {
this.api.showMsg("Error en getIds():" + err);
});
this.oneSignal.endInit();
}
Ionic info:
Ionic:
Ionic CLI : 5.4.1 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.2
#ionic/app-scripts : 3.2.1
Cordova:
Cordova CLI : 9.0.0 (cordova-lib#9.0.1)
Cordova Platforms : ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.3.1, (and 14 other plugins)
Utility:
cordova-res : not installed
native-run : not installed
System:
NodeJS : v10.16.3 (/usr/local/bin/node)
npm : 6.9.0
OS : macOS Mojave
Xcode : Xcode 11.2.1 Build version 11B500
cordova plugin list:
cordova-open-native-settings 1.5.2 "Native settings"
cordova-plugin-actionsheet 2.3.3 "ActionSheet"
cordova-plugin-advanced-http 2.0.2 "Advanced HTTP plugin"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-dialogs 2.0.1 "Notification"
cordova-plugin-email-composer 0.9.1 "EmailComposer"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-geolocation 4.0.1 "Geolocation"
cordova-plugin-googlemaps 2.4.6 "cordova-plugin-googlemaps"
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 2.3.1 "cordova-plugin-ionic-webview"
cordova-plugin-network-information 2.0.2 "Network Information"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
mx.ferreyra.callnumber 0.0.2 "Cordova Call Number Plugin"
onesignal-cordova-plugin 2.4.6 "OneSignal Push Notifications"
Running the project on XCODE IPhone simulator (Target iOS 13.2.2 / iPhone 11) working fine, making the subscription and getting the player id.
It just doesn't work on real devices iPhone 13.x.
any suggestions?
Best Rgs

Update your onesignal plugin with version 2.6.0 or above, then it's working fine in ios 13 .

Related

ionic ios white screen after splash main.js not exist

I've been trying to run in xcode a project with this specifications
The problem I can see in the console of Safari is that the javascript files are not loaded.
I generate the XCode project by
ionic capacitor add ios
Ionic: Ionic CLI : 6.18.2 (C:\NVM\v12.20.0\node_modules\#ionic\cli)
Ionic Framework : ionic-angular 3.9.2
#ionic/app-scripts : 3.2.4 Capacitor: Capacitor CLI : 3.4.3 #capacitor/android : 3.4.3
#capacitor/core : 3.4.3
#capacitor/ios : 3.4.3
Cordova:
Cordova CLI : 11.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.0.5, cordova-plugin-ionic-webview
Utility:
cordova-res : 0.15.4
native-run : 1.5.0
System: NodeJS : v12.20.0 (C:\Program Files\nodejs\node.exe)
npm : 6.14.8
OS : Windows 10

Ionic CORS issue on iOS device, while correct headers are set

I have some issue with ionic CORS on an iOS device. Now, I know that CORS issue should be solved mainly from the server. As I have fool control over the backend I set the following headers on the Apache Vhosts file.
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: *
Access-Control-Allow-Headers: *
And it works, I have inspected headers and see that they are set. Android app works without any issue both in simulators and live devices. iOS app also works without any issue in any simulator I try. So it seems that the only issue I have is on a real iPhone that doesn't run app and shows CORS error.
As can be seen from the headers I have allowed anything that was possible to allow and don't get why the webview throws the error on an iOS device while all the headers are set correctly.
Here is some more info about my ionic setup
Ionic CLI : 6.10.1 (/usr/local/lib/node_modules/#ionic/cli)
Ionic Framework : ionic-angular 3.9.2
#ionic/app-scripts : 3.2.4
Cordova:
Cordova CLI : 9.0.0 (cordova-lib#9.0.1)
Cordova Platforms : android 8.1.0, ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 18 other plugins)
Utility:
cordova-res : not installed
native-run : 1.0.0
System:
Android SDK Tools : 26.1.1 (/Users/someuser/Library/Android/sdk)
NodeJS : v12.18.2 (/usr/local/bin/node)
npm : 6.14.5
OS : macOS Catalina
Xcode : Xcode 11.6 Build version 11E708
Here is the error I get
[Error] Request header field Content-Type is not allowed by Access-Control-Allow-Headers.
[Error] XMLHttpRequest cannot load https://app.example.com/oauth/token due to access control checks.
[Error] Backend returned code 0, body was: {"isTrusted":true}
(anonymous function) (cordova.js:1732)
handleErrors (main.js:2334)
error (vendor.js:68778)
_error (vendor.js:98287)
error (vendor.js:20453)
_error (vendor.js:20479)
error (vendor.js:20453)
_error (vendor.js:20479)
error (vendor.js:20453)
notifyError (vendor.js:22047)
_error (vendor.js:140032)
error (vendor.js:20453)
_error (vendor.js:20479)
error (vendor.js:20453)
onError (vendor.js:62444)
onInvokeTask (vendor.js:5126)
runTask (polyfills.js:3:10845)
invokeTask (polyfills.js:3:16802)
p (polyfills.js:2:27655)
v (polyfills.js:2:27895)
[Error] Failed to load resource: Request header field Content-Type is not allowed by Access-Control-Allow-Headers. (token, line 0)
Here are plugins installed
> cordova plugin ls
com-badrit-base64 0.2.0 "Base64"
cordova-plugin-advanced-http 1.11.1 "Advanced HTTP plugin"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-badge 0.8.8 "Badge"
cordova-plugin-camera 4.1.0 "Camera"
cordova-plugin-device 2.0.3 "Device"
cordova-plugin-dialogs 2.0.2 "Notification"
cordova-plugin-file 6.0.2 "File"
cordova-plugin-file-transfer 1.7.1 "File Transfer"
cordova-plugin-geolocation 4.0.2 "Geolocation"
cordova-plugin-inappbrowser 3.2.0 "InAppBrowser"
cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 5.0.0 "cordova-plugin-ionic-webview"
cordova-plugin-local-notification 0.9.0-beta.3 "LocalNotification"
cordova-plugin-network-information 2.0.2 "Network Information"
cordova-plugin-request-location-accuracy 2.3.0 "Request Location Accuracy"
cordova-plugin-screen-orientation 3.0.2 "Screen Orientation"
cordova-plugin-splashscreen 5.0.4 "Splashscreen"
cordova-plugin-uniquedeviceid 1.3.2 "UniqueDeviceID"
cordova-plugin-whitelist 1.3.4 "Whitelist"
cordova-sqlite-storage 2.6.0 "Cordova sqlite storage plugin"
cordova.plugins.diagnostic 4.0.12 "Diagnostic"
es6-promise-plugin 4.2.2 "Promise"
ionic-plugin-keyboard 2.2.1 "Keyboard"
After spending several hours on debugging, I found out that the issue was that it doesn't accept wildcard for Access-Control-Allow-Methods and Access-Control-Allow-Headers
So the server headers look like this now.
Header set Access-Control-Allow-Origin: "*"
Header set Access-Control-Allow-Methods: "GET, POST, PUT, PATCH, DELETE"
Header set Access-Control-Allow-Headers: "Content-Type, Authorization, Accept, timeout"
The one drawback of this that I had to inspect all the code and include all the HTTP methods and headers that are in use throughout the app.
My understanding is that the issue was because of the Authorization header which cannot be wildcarded. And because it contains credentials, methods should be stated explicitly as well.
Now it works in all devices and simulators.

ionic3 ios13 InAppbrowser crash

I'm creating ios13 app in Ionic3.
But ios13Beta2 is not working in InAppBrowser.
so select param '_blank', this app is crash.
This is error detail.
[TraitCollection] Class _UIFullscreenPresentationController overrides
the -traitCollection getter, which is not supported. If you're trying
to override traits, you must use the appropriate API.
My ionic environment
Ionic:
Ionic CLI : 5.0.3
Ionic Framework : ionic-angular 3.9.6
#ionic/app-scripts : 3.2.4
Cordova:
Cordova CLI : 9.0.0 (cordova-lib#9.0.1)
Cordova Platforms : ios 5.0.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 1.2.1, (and 14 other plugins)
Utility:
cordova-res : not installed
native-run : not installed
System:
ios-sim : 8.0.1
NodeJS : v12.4.0
npm : 6.9.0
OS : macOS Catalina
Xcode : Xcode 11.0 Build version 11M337n
I was facing the same issue
but finally got it resolved by downgrading the WKView
It's one of the temporary solutions until we are able to get a concrete one.
https://ionicframework.com/docs/v3/wkwebview/
you can do it by adding this in config.xml
<platform name="ios">
<preference name="CordovaWebViewEngine" value="CDVUIWebViewEngine" />

Metadata version mismatch for module after creating IOS build ( node_modules/#ionic-native/network/index.d.ts, found version 4, expected 3 )

When i am trying to create IOS build getting error like below.
Error: Metadata version mismatch for module /Users/newuser/WebstormProjects/myproject/node_modules/#ionic-native/network/index.d.ts, found version 4, expected 3
at StaticSymbolResolver.getModuleMetadata (/Users/newuser/myproject/node_modules/#angular/compiler/bundles/compiler.umd.js:24474:34)
at StaticSymbolResolver._createSymbolsOf (/Users/newuser/myproject/node_modules/#angular/compiler/bundles/compiler.umd.js:24260:46)
at StaticSymbolResolver.getSymbolsOf (/Users/newuser/myproject/node_modules/#angular/compiler/bundles/compiler.umd.js:24241:14)
at /Users/newuser/myproject/node_modules/#angular/compiler/bundles/compiler.umd.js:23023:30
at Array.forEach (native)
at extractProgramSymbols (/Users/newuser/myproject/node_modules/#angular/compiler/bundles/compiler.umd.js:23022:79)
at AotCompiler.compileAll (/Users/newuser/myproject/node_modules/#angular/compiler/bundles/compiler.umd.js:22720:47)
at CodeGenerator.codegen (/Users/newuser/myproject/node_modules/#angular/compiler-cli/src/codegen.js:30:14)
at Function.NgTools_InternalApi_NG_2.codeGen (/Users/newuser/myproject/node_modules/#angular/compiler-cli/src/ngtools_api.js:61:30)
at Object.doCodegen (/Users/newuser/myproject/node_modules/#ionic/app-scripts/dist/aot/codegen.js:6:51)
cli packages:
#ionic/cli-utils : 1.16.0
ionic (Ionic CLI) : 3.16.0
global packages:
cordova (Cordova CLI) : 7.0.1
local packages:
#ionic/app-scripts : 2.1.3
Cordova Platforms : android 6.3.0 browser 4.1.0 ios 4.4.0
Ionic Framework : ionic-angular 3.6.0
System:
Node : v6.11.1
npm : 3.10.10
OS : macOS Sierra
Xcode : Xcode 8.3.3 Build version 8E3004b
Environment Variables:
ANDROID_HOME : not set
Misc:
backend : legacy

ion-select component of Ionic 3 not working in IOS 9

We have developed one application using Ionic 3. We have used ion-select component at multiple places. In android & IOS version > 10, everything is working fine as expected.
But In IOS 9, ion-select component breaks. It shows blank options when tapping on ion-select.
<ion-item>
<ion-label>Gender</ion-label>
<ion-select>
<ion-option value="f">Female</ion-option>
<ion-option value="m">Male</ion-option>
</ion-select>
</ion-item>
Result:
Environment Details:
Specific IOS version in which issue is reproducible: 9.3.5
global packages:
#ionic/cli-utils : 1.5.0
Cordova CLI : 6.5.0
Ionic CLI : 3.5.0
local packages:
#ionic/app-scripts : 1.3.7
#ionic/cli-plugin-cordova : 1.4.1
#ionic/cli-plugin-ionic-angular : 1.3.2
Cordova Platforms : android 6.1.2 ios 4.2.1
Ionic Framework : ionic-angular 3.7.1-201710060319
System:
Node : v7.8.0
OS : OS X El Capitan
Xcode : Xcode 8.2.1 Build version 8C1002
ios-deploy : 1.9.1
ios-sim : 5.0.13
npm : 4.2.0
I was able to resolve the issue by downgrading the app-scripts version to 2.1.4 from 3.0.1.
I also had to add dev dependency tsc-wrapped to resolve some ts lint issues.
"devDependencies": {
"#angular/tsc-wrapped": "^4.4.6",
"#ionic/app-scripts": "2.1.4",
"typescript": "2.3.4"
},
After changing my configuration to above, the webpack process duration came down to 3-4 minutes from 35 minutes.

Resources