ngx-translate not working on iOS device (Cordova) - ios

First, I've read the previous threads regarding this. And none of the solutions worked for me.
I have a Cordova-based app (not ionic) which is deployed on android and iOS. Everything works fine except that my translations doesn't work on iOS devices (neither simulator or real device). I'm using ngx-translate and it there's no problem in the browser or on Android-devices.
Here's my setup:
app.module.ts
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
}),
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
app.component.ts
import localeSv from '#angular/common/locales/sv';
ngOnInit(): {
this.translate.setDefaultLang('se');
registerLocaleData(localeSv);
}
Implementation:
<div translate>Click to close</div>
I've also tried using other translate styles like this.translateService.instant('something'), but it's not working.
After running cordova build ios I can see that my se.json file is in the correct folder: /assets/i18n/se.json
Version info:
"#ngx-translate/core": "^11.0.1",
"#ngx-translate/http-loader": "^4.0.0"
9.0.0 (cordova-lib#9.0.1)
ios 5.1.1
using WKWebViewOnly
allowing all http-intent and http-navigation in config.xml
Plugins:
cordova-plugin-customconfigparameters 3.0.0 "Custom Config Parameters"
cordova-plugin-device 2.0.3 "Device"
cordova-plugin-geolocation 4.0.2 "Geolocation"
cordova-plugin-splashscreen 5.0.3 "Splashscreen"
cordova-plugin-whitelist 1.3.4 "Whitelist"
cordova-plugin-wkwebview-engine 1.2.1 "Cordova WKWebView Engine"
onesignal-cordova-plugin 2.9.0 "OneSignal Push Notifications"
skwas-cordova-plugin-datetimepicker 2.1.1 "DateTime picker"
If anyone has any idea of what it could be I'd really appreciate the help. Been stuck on this for days.

If there's anyone else with the same problem. I solved it by loading my json file and setting the translation manually:
Import your .json file:
import jsonSe from '../assets/i18n/se.json';
Use the translation service to set language manually:
let jsonSeData = (jsonSe as any);
this.translate.setTranslation('se', jsonSeData, true);

try to add this lines to your config.xml if you are using wkwebview (cordova ios 6.0.0)
This can be found in the documentation: https://cordova.apache.org/announcements/2020/06/01/cordova-ios-release-6.0.0.html
<preference name="scheme" value="app" />
<preference name="hostname" value="localhost" />

Related

UIWebView references in blank ionic project

I am going through a nightmare regarding the UIWebView depreciation by Apple. I am in the process of identifying the cordova plugins and hopefully will find solutions. However, when I start from a blank ionic project, I still see references with respect to UIWebView and puzzled by it. Below please find the steps I followed:
1) ionic start testProject blank --cordova
2) Add the below into the ios section of the config.xml:
<preference name="WKWebViewOnly" value="true" />
<feature name="CDVWKWebViewEngine">
<param name="ios-package" value="CDVWKWebViewEngine" />
</feature>
<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
3) ionic cordova prepare ios
4) cd platforms/ios
5) grep -Ri UIWebView
At this point, I see references at CDVUIWebViewEngine.m
If I were to install the following:
ionic cordova plugin add cordova-plugin-inappbrowser
npm install #ionic-native/in-app-browser
I also see references related to inappbrowser
I am not sure what is going on with such a basic structure. I'd grateful for any pointer you may have as I have been pulling my hairs for the last two days.
Below is my setup:
Ionic:
Ionic CLI : 6.7.0 (/home/doug/.npm-global/lib/node_modules/#ionic/cli)
Ionic Framework : #ionic/angular 5.1.1
#angular-devkit/build-angular : 0.901.7
#angular-devkit/schematics : 9.1.7
#angular/cli : 9.1.7
#ionic/angular-toolkit : 2.2.0
Cordova:
Cordova CLI : 9.0.0 (cordova-lib#9.0.1)
Cordova Platforms : ios 5.1.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 6 other plugins)
Utility:
cordova-res : 0.14.0
native-run (update available: 1.0.0) : 0.2.9
Thanks,
Doug

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

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 .

Ionic 4 Ios build getting blank screen

I am getting Failed to load resource: The requested URL was not found on this server. error when run app in iOS emulate and device, it is working fine in Android.
I have updated iOS platform version but still getting same error. I have try with removing plugin but still same error. Check screenshot
I have setup new blank ionic 4 project and build ios it is working fine.
Ionic:
Ionic CLI : 5.4.1 (/usr/local/lib/node_modules/ionic)
Ionic Framework : #ionic/angular 4.8.1
#angular-devkit/build-angular : 0.13.9
#angular-devkit/schematics : 7.2.4
#angular/cli : 7.3.9
#ionic/angular-toolkit : 1.4.1
Capacitor:
Capacitor CLI : 1.0.0-beta.24
#capacitor/core : 1.0.0-beta.24
Cordova:
Cordova CLI : 9.0.0 (cordova-lib#9.0.1)
Cordova Platforms : android 8.1.0, ios 4.4.0
Cordova Plugins : cordova-plugin-ionic-webview 4.1.3, (and 15 other plugins)
Utility:
cordova-res : 0.6.0 (update available: 0.8.1)
native-run : 0.2.8 (update available: 0.2.9)
System:
Android SDK Tools : 26.1.1 (/Users/chetan/Library/Android/sdk)
ios-deploy : 1.9.4
NodeJS : v10.15.3 (/usr/local/bin/node)
npm : 6.4.1
OS : macOS Catalina
Xcode : Xcode 11.1 Build version 11A1027
I find at a solution for this problem, follow the next step:
1) close Xcode;
2) Make sure localhost is allowed in config.xml:
<allow-navigation href="http://localhost:8080/*" />
<preference name="CordovaWebViewEngine" value="CDVUIWebViewEngine" />
<platform name="ios">
...
Run
$ ionic cordova plugin remove cordova cordova-plugin-ionic-webview --save
$ rm -rf platforms/
$ rm -rf plugins/
inside of the tag platform ios
<feature name="CDVWKWebViewEngine">
<param name="ios-package" value="CDVWKWebViewEngine" />
</feature>
<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
finally run:
ionic cordova build ios
I have found solution of the error
Adding WKWebView to your app
In order to add WKWebView, we need to add the plugin from the Ionic repository.
ionic cordova plugin add cordova-plugin-ionic-webview --save
If you already had the plugin installed, or were using a different version/fork, you’ll need to uninstall what you have first.
ionic cordova plugin rm cordova-plugin-WKWebView-engine
And that’s it! Once the plugin install is done, your next native build will include a faster, lighter, and more modern webview!
https://ionicframework.com/blog/wkwebview-for-all-a-new-webview-for-ionic/

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" />

PushPlugin not found for iOS PhoneGap

I just installed PhoneGap 3.5 and the PushPlugin using the PhoneGap CLI. I created a project using the PhoneGap CLI. In the receivedEvent method of index.js, I added these lines:
var pushNotification = window.plugins.pushNotification;
pushNotification.register(myTokenMethod, onError, {"badge": "true", "sound": "true", "alert":"true", "ecb": "mycallback"}
this leads to the error in xCode of:
CDVPlugin class PushPlugin (pluginName: PushPlugin) does not exist
ERROR: Plugin 'PushPlugin' not found or is not a CDVPlugin. Check your plugin mapping in config.xml
And although the instructions do not indicate I need to for automatic installation of the plugin, I went ahead and added
<feature name="PushPlugin">
<param name="ios-package" value="PushPlugin" />
</feature>
to my config.xml and receive the same error. The plugin version is 2.4, I am using an iPhone 6 as a test device and xCode 6.
Any ideas where to look?
Make sure your PushPlugin.m inside Build Phases > Compile Sources

Resources