iOS don't killing correctly app - Ionic - ios

When you leave the application approximately 3 or more hours in iOS in the background, it does not kill the application correctly, this causes index.html to be blank in the safari development console.
engine name="ios" spec="4.4.0"
Ionic info
ionic -version 3.20.0
ionic info
cli packages: (C:\Users\Usuario Interax\AppData\Roaming\npm\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.6
Ionic Framework : ionic-angular 3.9.2
System:
Node : v6.11.5
npm : 5.6.0
OS : Windows 10
Misc:
backend : pro
I found this print in console:
exception nativeEvalAndFetch : ReferenceError: Can't find variable: cordova
global code about:blank 1:127
global code script element 1:1:127
The application stop in splashscreen and don't go to principal screen.
Searching more thoroughly found this:
exception nativeEvalAndFetch : ReferenceError: Can't find variable: cordova
try {
cordova.require('cordova/exec').nativeEvalAndFetch(function() {
cordova.fireDocumentEvent('active');
})
} catch (e) {
console.log('exception nativeEvalAndFetch : ' + e);
};
The bug only happens in iOS, Android works good.

Cheking this post: https://www.outsystems.com/forums/discussion/35329/post-ios-11-3-mobile-app-freeze-crash-on-resume-after-sleep-silk-ui/
I tested it in iOS version 10.3.3 and the function of the application is correct, so there is an error in the new version 11.3 and also in the 11.4.

The issue was fixed in a pullrequest in the cordova-ios repository (see https://github.com/apache/cordova-ios/pull/363/files 38). Nevertheless, there does not exist an update with this PR yet. Therefore, I decided to download the fixed file and after adding the ios platform, I replace the old CDVViewController.m on my own. For me this worked and my > 2000 user do not experience this issue anymore.
The path to the old file is platforms/ios/CordovaLib/Classes/Public/CDVViewController.m.
Remember to replace this file everytime after removing/adding the platform. I use for this (and other things) a shellscript to prepare my working directory before building.
I hope this will help you.
Gratitude Mike1707 to provide a workaround Forum response https://forum.ionicframework.com/t/problem-with-ios-in-the-background-after-time/131592/6

Related

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.

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?

Ion-input loses focus while using bluetooth keyboard

I am working on entering text with Hardware keyboard(Bluetooth connected) connected to iPhone(iOS 9 and iOS 10) in Ionic 3. While entering, The input is losing its focus and even if i try to enter again, It is not taking any input from keyboard. This hardware keyboard is working well in Android phone but not in iOS.
I tried upgrading/re-installing updated keyboard plugin from Cordova. But no luck with that.
The below is my Ionic Info.
cli packages: (/usr/local/lib/node_modules)
#ionic/cli-utils : 1.12.0
ionic (Ionic CLI) : 3.12.0
Global Packages:
cordova (Cordova CLI) : 6.5.0
Local Packages:
#ionic/app-scripts : 2.1.3
Cordova Platforms : android 6.1.2 browser 4.1.0 ios 4.1.1
Ionic Framework : ionic-angular 3.6.0
System:
ios-deploy : 1.9.1
ios-sim : 5.0.13
Node : v7.4.0
npm : 5.0.3
OS : macOS Sierra
Xcode : Xcode 8.3.3 Build version 8E3004b
Misc:
backend : pro
If any ideas, Please let me know. Thank you.
EDIT
I tried with downgrading Ionic from 3.12 to 2.18. Still no luck. Input field still looses focus within milliseconds.
Install the Keyboard plugin.
In app.components.ts 's constructor :
platform.ready().then(() => {
keyboard.hideKeyboardAccessoryBar(false);
});
There are couple of things that need to be verified here , issue you are facing is something that is related to the WebViews especially for the iOS , so let's start from the Keyboard, try to install the ionic-plugin-keyboard
cordova plugin add ionic-plugin-keyboard --save
if you need more events related to how you want to trigger the Keyboard events refer the official doc
i generally use the ionic-wkwebview rather than going with the in build webview of iOS which resolves most of the problem. You can install the plugin as follows:
ionic cordova plugin add cordova-plugin-ionic-webview --save
For complete installation refer the ionic-wkwebview-official doc
Even for the ionic-plugin-keyboard , there was issue with the ion-input but it was resolved and issue is not with the plugin but with the Webview,
Here is the reference to that issue which got resolved .

'cordova build ios' create the app with 107 issues

So my app i ready, i build the app with ionic v1 + cordova for android + ios by phpstorm and cordova cli.
The android working perfect!
but when i build the ios i open the .xcworkspace with the xcode and click on run and it's runnig on the iphone but with 107 issues.
And the issues it's from the plugins...
By the way for to success to running on ios I had to change the file Podfile to this:
# DO NOT MODIFY -- auto-generated by Apache Cordova
platform :ios, '8.0'
target 'xxx' do
project 'xxx.xcodeproj'
pod 'FirebaseMessaging', '~> 2.0.0'
pod 'GoogleToolboxForMac'
pod 'Google'
end
Someone have any idea how to fix that?
because, the push notification half working, i get the token but i don't get the notification on the phone, and yes i created all the certificate
my ionic info
cli packages: (/usr/local/lib/node_modules)
#ionic/cli-utils : 1.13.0
ionic (Ionic CLI) : 3.13.0
global packages:
cordova (Cordova CLI) : 7.1.0
Gulp CLI : CLI version 3.9.1 Local version 3.9.1
local packages:
Cordova Platforms : ios 4.5.2
Ionic Framework : ionic1 1.3.3
System:
ios-deploy : 1.9.2
ios-sim : 6.0.0
Node : v6.10.2
npm : 5.4.2
OS : macOS Sierra
Xcode : Xcode 9.0 Build version 9A235
Misc:
backend : legacy
Thank you!
This is normal behaviour, plugins are created by the community and not always up to date, this is why you are seeing so much deprecation warnings. But these are just warnings so they should not cause any trouble, they are just there to inform you that this should probably be fixed some time in the future before the deprecated methods get removed from the SDK.
If you want to fix all of them as you asked you will have to fork every plugin you use and replace the deprecated parts with its successors.
The problem with your push notifications is related to something else and you should as another question with more detailed information on that.

Ionic v1 app not working properly in ipad while it works on other devices

I am facing one of the strangest problem.My ionic v1 app works fine in android and iphone but it is not working properly in ipad. My app has four tabs one of the tab is home which loads 'home' view to which 'HomeController' is binded, but somehow this controller fails to load while app running in ipad i.e angularjs is unable to find the 'HomeController'.
Below is the Xcode log screenshot displaying "HomeController" error.
As we can see in the above Xcode log screenshot angularjs is unable to find and load "HomeController".
i have also checked for any case error in name while including "HomeController.js" file in index.html that is also correct.Also i have checked for any Dependency injection error but everything is right if it was not then app would not run on any device.
Below is configuration information-
#ionic/cli-utils : 1.9.2
ionic (Ionic CLI) : 3.9.2
global packages:
Cordova CLI : 7.0.1
Gulp CLI : not installed globally
local packages:
Cordova Platforms : android 6.2.3 ios 4.4.0
Ionic Framework : ionic1 1.3.1
System:
Node : v6.11.2
npm : 3.10.10
OS : macOS Sierra
Xcode : Xcode 8.3.3 Build version 8E3004b
Ipad's ios version:-9.3.5
Thank You.
After so much googling and debugging, finally i found the problem. the main problem was that i was using 'let' to declare variable in 'strict mode' and i was unable to see the problem because lack of xcode to show verbose log.
so to display appropriate error message i placed below code in index.html before loading any javascript files.
index.html
<script type="text/javascript">
window.onerror = function (errorMsg, url, lineNumber) {
alert('Error: ' + errorMsg + ' Script: ' + url + ' Line: ' + lineNumber);
}
</script>
i specially thank karma for the above code in this answer

Resources