Ionic 2 - Native File issue with JSON.parse on iOS - ios

I'm having a problem when deploying my Ionic2 app on iOS real device. Testing it in web and Android real device works fine but when running my app on a iPhone I have a problem when parsing data retrieved from reading a local file (using #ionic-native/file).
After checking that the file exists, I read it like this:
this.file.readAsText(this.file.cacheDirectory + 'epg/', fileName)
.then( (data) => {
console.log('read file - then 1');
console.log(data);
this.channels = JSON.parse(data);
console.log('read file - then 2');
Debugging it in Xcode console I see this:
"read file - then 1"
"(empty string)"
"TIC Read Status [2:0x0]: 1:57" (4 times)
It never gets to the second log, but it neither has an error in the logs....
When I run it in android device, I get the first log, then all the data read from the file and then the second log and everything works fine but in iOS it stops in the 'JSON.parse' line without error but the device continue in a loading state and it never stops. Seems like there were an error but no error detected...
Any help? Thanks!!!

Check out this page: https://ionicframework.com/docs/wkwebview/#rewriting-file
You should try using normalizeURL(this.file.cacheDirectory + 'epg/')

Solved it removing the platform (ionic cordova platform rm ios) and installing it again!

Related

ionic4-iOS white screen in iOS Simulator

I'm using XCode11 and ionic4. cordova version ios#5.0.0
project builds successfully using ionic cordova build ios
also successfull build in xcode
but when running on simulator, it end up showing white screen and nothing happens next. here is the console output showing the issues:
Log1
Log2
stuck on this for 4 days. checked so many suggestions on ionic blogs and nothing worked so far. I regret using ionic because its very buggy/unstable... please help
ISSUES:
-Failed to load webpage with error: the operation couldnt be completed(NSURLErrorDomain error -999)
-NSURL Connection finished with error -code -1100
-ERROR: HTTP Request(OSRequestRegisterUser) must contain an app_id parameter
-ERROR: Encountered error during push registration with OneSignal
in addition to the above errors, the iOS simulator hangs on "White Screen", the application does not load and nothing happens next.
Try this:
On your xcode, navigate to your plugin folder, locate a file named OneSignalPush.m
Inside, locate the initOneSignalObject,
add this: appId = "your-app-id-here";
right after this code:
[OneSignal setValue:#"Cordova" forKey:#"mSDKType"];
That did the trick for me.

Error while running code in iOS, Getting Ionic HTTP Failure in Response

I developed my application in ionic 3 and my back-end is PHP PDO , my app is working perfectly in Android and all the web services are getting called perfectly.
I have imported my code in Mac Book and generated in Xcode. when I run that code in simulator API are not getting called and shows error as HTTP failure Response from unknown URL 0 Unknown Error.
I have already added white list Plugin in iOS
I have already added CSP in my index.html file
API are getting called in Safari Browser perfectly but not in simulator and real device.
Any help is appreciated.
I have Degraded ionic web view for ios and that worked for me.

Ionic IOS app NSURLConnection error 1100

I am trying to run my ionic app as a ios native app and am getting a strange URL connection error that is preventing the data from being populated on my app's view. When I run the App in the web browser as an iphone it runs and populates fine, but when running it on the native ios it doesn't populate the page as expected using the API data. I have checked the console and the API is in fact being called, but the xcode console is printing out the following for the 2 API calls which populate the page's data:
2018-02-19 11:30:21.199933-0500 MyApp[1429:350591] NSURLConnection finished with error - code -1100
2018-02-19 11:30:21.202556-0500 MyApp[1429:350591] NSURLConnection finished with error - code -1100
I have looked and seen that code -1100 is typically a file not found type of issue, but I am unsure of how this would be happening, as it is just an API call being made to return the data, which is then being stored in an ionic card format.
You can try with below steps:
1) Delete node modules,plugins folder
2) ionic cordova platform remove ios
3) npm install
4) ionic cordova platform add ios
5) ionic cordova build ios

trigger.io Error reading file

I use the forge.file.saveURL to save a JSON object to the local file system, then I use forge.file.String to read the contents and display them on the device.
This works just fine on IOS and Android but it seem on Android after the device has closed the app or force closed it after being open for a while when I reopen the app and try and access the file I get the error message in the console
Native call file.string with task.params:
{"uri":"file:///storage/sdcard0/Android/data/com.phonegap.conbop/files/Download/594f9cdc-a791-40ef-a40b-75d16948a9ca"}
[DEBUG] Returned: {"content":{"message":"Error reading
file","type":"UNEXPECTED_FAILURE","subtype":null},"callid":"508FE1AD-EB74-4377-8FDA-AA7318457B5C","status":"error"}
I have tested the IOS and this does not seem to happen there, its almost like the file is getting corrupt or something but what is strange is a also use the file.saveURL to save images etc and those work just fine so I'm not sure why this one is having issues.

PhoneGap + Sencha2 screen blank

I've started a project in PhoneGap which will utilise Sencha Touch 2.
I tried to change the app name from 'app', since I've heard that conflicts with PhoneGap on Android devices. I altered app.js to main.js and that worked, but then I tried changing the Ext.application.name. All I got was a white screen after the loading splash, even with the old name Sencha. Debug console shows nothing at all happening, and the document <body> was empty. This happens with both sencha-touch-all.js and sencha-touch-all-debug.js. Test device is an iPad 1G running iOS 4.3.5.
Aside: To debug this issue, I set up weinre on my Mac and added the appropriate <script> tag to index.html. After making that change, though, the app didn't even launch. It hung on the PhoneGap splash png and I got this message from gdb-remote:
error: failed to launch '<app URI>' -- failed to send the qLaunchSuccess packet
The only reference to that message besides its definition in gdb-remote source that I can find is here, and it's unrelated. I managed to get the issue to go away by restarting the iPad and removing build intermediates.
SOLVED: The issue here was a missing value in the Ext.application definition (key with no associated value), so the whole app definition probably tanked as a result of that. Hence blank screen.

Resources