IBM Worklight 5 - iOS app shows white screen on second launch - ios

I'm having a problem with a hybrid app for iOS which I have written using Worklight 5. The problem is that the application only runs properly the first time it is launched, and after being closed in multi-tasking and relaunched, the app will not open properly and instead displays a white screen. The only way to get the application to run again is to delete it from the device completely and then re-install it.
This behaviour is the same in the iPad simulator and on a physical iPad.
I don't have any code to provide as all of the Objective-C is generated by Worklight and all I have written is the HTML5, CSS3 and Javascript and I think that's unlikely to be affecting it. Has anybody else experienced this issue and if so is there a way to resolve this problem? Thanks.

Actually the behavior sounds to me much more inline with changing the name of the HTML file itself and in application-descriptor.xml's mainFile element. Have you touched these? If yes, then you also need to change the name of the application's folder.

Here's something to try:
Open cordova.js inside the Xcode project.
Replace: execXhr.open('HEAD', "/!gap_exec", true);
With execXhr.open('HEAD', "/!gap_exec?" + +new Date, true);.
It's from a fix that was applied to Cordova 2.4. It adds a timestamp to the query param to prevent caching.
No idea if that will help, it sounds vaguely familiar to an issue I ran into.

Related

phonegap iOS app working on simulator but not in device. How to debug

I just finished developing a Cordova / Phonegapp app. When I test it on iOS simulator it all works fine and quick, but, when testing on device it works only part of it.
My app is a game with the kingdom background and has 8 buttons (8 buildings).
When I click on each building it leads me to a screen representing what it's inside the building, but one of them doesn't work and gets my app frozen.
How can I see fail or crash reports that helps me debug my app on device?
If you provide full path to your file i.e. "file:///Users/.../someDir/some.html" it will work only on simulator running on the same machine where your project is.
I suggest just adding the additional path to the file you want to access i.e. if you are in "/someDir" you will need to provide only "some.html" or if you want to access parent directory just use "../".
As far as debugging Cordova app, I suggest downloading this plugin and using console.log instead of alert.
Hope this helped.
Ok, I found a "spartan" way to debug my app via alert and found that an url wasn't set properly (still don't know why it worked on simulator)

Cordova trying to dial telephone number

I am trying to dial a phone number in iOS, however I only have the simulator and an iPod Touch to test on.
The code uses something along the lines of:
window.location.href = 'tel:01234567890';
Working fine with Android, but in iOS it dies with:
Failed to load webpage with error: The URL can't be shown
Now, I do realise this has been asked before, but the general consensus from some time ago was "It doesn't work, you'll need to use a plugin". There haven't been many questions on this for some time though, and what questions there are seem to suggest it works when doing it programmatically (as above with window.location.href). I have tried the iOS PhoneDialer and the newer version of the same plugin, but both have errors in XCode (ARC forbids explicit message send of 'release') - a bit of faffing and I can get this running, but then PhoneGap doesn't find the plugin - it really feels like I'm hitting a brick wall with this method, and I can't believe something as simple as this requires something so over the top.
I know you cannot auto-dial/auto-call a number for security reasons, but all I need to do is open the dialer with number pre-populated, which is surely no different to a mailto:info#example.com link opening your email client with the sender pre-populated?
So, my questions are:
Has this changed with a recent update to PhoneGap, iOS or XCode?
Or, is it a case that I cannot do this on an iPod or Simulator, and it will work fine on an iPhone?
How can I fix it? :)
You didn't specify which version of Cordova you are using so I'm going to assume version > 3.
Make sure that InAppBrowser, a plugin since version 3, is installed and then open the link by calling it through Javascript like this:
window.open('tel:12345678', '_system')
_system will open it with the systems own browser which in turn will open the call dialog, if you use it against http://maps.apple.com/ it will open in the maps app and similar for other apps which opens for special urls.
Remarks:
As described in the docs of the InAppBrowser plugin the window.open function won't be set automatically. You have to do it your self: window.open = cordova.InAppBrowser.open;. Instead you can directly use cordova.InAppBrowser.open('tel:12345678', '_system');
Make sure your number doesn't have any blankspaces in it (the +
prefix is okay). For example you could use a function like the following,
assuming num is a string.
Function:
function placeCall(num) {
if (window.cordova) {
cordova.InAppBrowser.open('tel:' + num.replace(/\s/g,''), '_system');
}
}
Below Code works perfectly fine for iphone:-
window.open('tel:123456', '_system');
Simulator doesn't support dialer. No need to waste time.
Make sure that the phone number in your href also doesn't have any formatting in it, as on iOS it causes the link not to work in a PhoneGap App. So for example, use tel:0390005555, and not tel:(03) 9000 5555.
I don't believe this is a Cordova issue. I know in native iOS you cannot bring up the dialer on the simulator or on an iPod touch. You will need to test this on an actual iPhone.
I know this is a late answer time.
Try by adding // to the url. Like this tel://xxxxxxxxx and see if it works.
Worked for me in IOS 8.4, iPhone 6, 6+ as of today.

Adding CSS images - Phonegap

Im developing a phonegap application using xcode. For the design I have some jquery mobile icons to display for certain buttons. I want to host this jquery mobile stuff on the app rather than having a http link to it (and thus using more bandwidth etc).
On the simulator this works fine and the icons show up, but when put on the phone they dont, i presume i have to tell xcode to put the image files on the phone explicitly? In a .plist or something.
Anyone have any insight?
Thanks
All the phonegap resource should be put in path www.
I never get the thing you described, but i think the error may occur because of your path of image. You may change the folder of jqm and try again.

How to create a HTML link to a build.phonegap app?

I have run into several problems with iOS development through phonegap recently, and unusually people around here have been unable to discuss these issues and even together we have (for the first time I have ever seen) not had a single comment or answer for these topics...
See https://stackoverflow.com/questions/14707936/make-a-page-that-redirects-back-to-ios-phonegap-app and iOS broswer data -> Cache & Cookie for Phonegap App / Session?...
However, I have found "solutions" to get around these, but its by no means answers to the issues in question which are still outstanding... just simply doing it a completely different way.
However, despite loosing web-view in phonegap, in an attempt to get around https://stackoverflow.com/questions/14707936/make-a-page-that-redirects-back-to-ios-phonegap-app I now have some issue that are outstanding...
I need to be able to navigate back to my App from the web-system !!!
However, I have no idea how. I have read info on creating URL Schema, but I am not sure if this is even possible through build.phonegap at all... and it seems faily complicated. Does anybody know of a way for iOS safari to do one of two things
Either
Open the app that is running in the background
or
close the current browser tab and navigate back to the app in the background.
The closing tab idea would be good, but not essential
Look forward to everyone thoughts and opinions on this one...
Henry
You can create an url scheme for any application you make yourself.
See tutorial here
It's not as terribly complicated as one would think, and the required objective-c code is minimal.
Once you have done this, you can use your own url scheme to launch your phonegap application from safari with a hyperlink.
This would not close the tab (you could do this with javascript if you wanted to)
but does put safari in the background, and opens your phonegap app.
(whether it is already running in the background or not)
It is even possible to pass data to the app using your url scheme.
It is not currently possible using PhoneGap Build in 2.2 and previous. Potentially a feature top be released in newer versions of Cordova/Phonegap

Anyone experience caching issues with web apps ran in full-screen mode iOS/Mobile Safari?

I'm having a very strange issue with my web app (which is ran in full-screen mode from the home screen) and Mobile Safari. Usually, as I develop, I edit the files with the changes that I want to make and then I re-launch the app from the homescreen. As per iOS design, the web app will refresh and reload the site.
However, in some odd but frequent situations, when I launch the application I get a cached older version of the app. If I navigate to the app through Mobile Safari (not from home screen) then everything looks great.
I've added meta no cache tags all over the space and even attempted to thwart the cache by adding ?query strings to .css files, etc, but for some odd reason when a cached version decides it wants to display - it will display, no matter what. Clearing cache and data from the settings menu and then relaunching will only sometimes fix the problem.
Anyone else run into this issue? If so, how did you fix it? Is it a known iOS bug? I'm thinking about adding some onLoad code to check if the application is running in full screen mode and then explicitly force a refresh.
Please help - this is extremely annoying and frustrating!
Rich
In my own testing I also found that applications run from the "Home Screen" on iOS won't properly refresh their CSS and JS files. This appears to be an ongoing problem. The only solution that worked for me was to:
Change the device date forward by 2 days or so..
Reload the app from the Home Screen..
Reset the date.
I also tried deleting and recreating the icon from the home screen and clearing the cache in Safari.
"Happily" you are not the only one seeing this problem.
https://discussions.apple.com/thread/3385843?start=90&tstart=0
Incase anyone asks. There were no manifest files involved in my testing.
iPad 2 with IOS 5.1.1.
Enable Debug console from "Settings>Safari>advance" and see if you've any errors there.
Most probably you may have an 'Invalid MIME type", Manifest Parsing or Resource Fetch Failure Error.
Fix them (this link might help in fixing those http://www.fuckyeahtml5.com/2011/06/debugging-html5s-offline-web-apps/).

Resources