I have dowloaded an xml file that contains some update parameters and then I need to reload these parameters and init some views. Easiest way is to apply this configuration on next app boot. Is there any way to reboot iOS application programmatically?
Thank you.
Rebooting the app is a bad idea, I'm pretty sure Apple would reject it. However, You could display a popup telling the user to open a close the app to apply your updated information. But the best way would be just to manually call the methods needed to rebuild your app (I.e. the ones that need to use the updated data).
If you have to do some extensive rebuilding (i.e. things that the user would immediately notice) it might be a good idea to add in a "loading" progress bar of sorts.
You can't reboot your app, and I don't see why you would a) have to b) EVER WANT TO.
You can quit and restart an iOS app with a bit of user assistance. Set the app's plist key for application exits on suspend. Create a local notification for your app to trigger a few seconds into the future. Then send Safari a URL. The OS will terminate your app when launching Safari to handle the URL. The URL might be to a web landing page telling the user that a relaunch is in progress. Then the local notification will go off and ask the user to relaunch your app.
However an app should be (re)designed so that there is never a reason to do this.
You can do it only if your device is jailbroken
Put a reboot button in your app and call abort();. This will crash the app.
Hook the -(void)exitedAbnormally; from SBApplication and write code to launch your app.
If its not jailbroken, you have no choice
if you develop for jailbroken devices you can use uicache command to clean the springboard cache and reload new apps/icons (available from UIKit package).
for example,
1) if you're under root:
su mobile -c uicache 1>/dev/null 2>&1
2) if you're under mobile:
uicache
for reboot you can use rebootcommand under root and killall SpringBoard for respring
Related
I am developing an app that uses push notifications, and testing on a device with iOS 5.1.1. I would like to test the scenario where the user is prompted about push notifications during the app's first run. The dialog appears the first time I call registerForRemoteNotificationTypes, but never appears again, even if the app is re-installed from scratch. How can I clear the setting so that the dialog will appear again?
The same question was posted before, but the answers do not work for iOS 5 or later, as noted in the comments there.
Apple's documentation says to uninstall the app and mess with the clock to make it look like the app was uninstalled for a day, but this does not work on iOS5.
Another answer suggested running General -> Reset -> Erase All Content And Settings - I tried this, but it froze my device and I ended up having to power-cycle it. In any case, this is a heavy-handed solution that is not practical for testing.
Another answer suggested removing your app's entry from /private/var/mobile/Library/RemoteNotification/Clients.plist, but this file does not exist on iOS5.
Is there a way to accomplish this on iOS5?
I found a solution that works if your device is jailbroken:
Use an app like iFile to open the file /var/mobile/Library/SpringBoard/applicationstate.plist with a property list viewer
Find your app's bundle identifier and delete the key SBRemoteNotificationClient
Restart SpringBoard - either reboot the device, SSH to the device and run killall SpringBoard, or use the Respring app.
Next time you run your app, it will show the notification permission dialog once again.
I've tested this on iOS 5.1.1.
Provided your code paths for iOS 5 and iOS 6 aren't too different, the easiest option is probably to just test that specific behaviour on iOS 6 — the callbacks you get on iOS 5 should be similar enough for it not to be an issue.
Alternatively, change the app's bundle ID. Slightly tedious (in the past I've needed to restart Xcode for it to notice that change in bundle ID), and you'll need a wildcard provisioning profile handy.
I have read some bits and pieces here and there about multitasking, but I am not sure I grasp it all. Basically, I have an iPhone app that runs quite ok on the iPhone simulator (I have yet to pay the dev fee to be able to deploy to an actual iPhone).
In the simulator, I can enter and exit the app, without issue. When I open the multitasking bar (double tap on the home button), I can close the app. When I try to reopen it, I then get an error.
I wonder, is this because testing closing and opening the app from multitasking is only possible on an actual iPhone, or are the some additional events I should be listening to? I have read this: http://www.cocos2d-iphone.org/forum/topic/8767 and added some handlers, but this article feels dated, and it didn't change anything.
Any help is appreciated!
The post about SIGKILL is correct. It is normal behavior for your application. Xcode is just reporting what killed your application the last time. Simply stop the execution and run your app again, and you should be fine.
As Richard said, that is normal. If you want to test it yourself:
Run the app using Xcode.
Stop the app using Xcode. (Press the Stop button which is directly to the right of the run button.
Launch the app by clicking on it in the Simulator's home screen.
Close the app and then close it from the multitasking bar.
Launch it again.
Good luck :)
We have built an Cydia app for jailbroken iPhones. Now my client wants the app to launch on it's own after the user hits the home button to pull the phone out of sleep mode. How can I accomplish this?
This would require you to redefine the functionality of the home button, or at the very least add functionality to, which Apple does not allow. It is possible, but it will get rejected from the app store.
EDIT: Didn't notice this was for jail broken iPhones, so yes you can do this. You would need to find custom Libraries, I don't know of any of the top of my head. Alternatively you could figure out what part of the private Apple API you need to use to do this.
Please note that changing button functionality is not the best of ideas... Perhaps you could accomplish the same thing by running in the background and using push notifications when user interaction is required?
zmaster pulled this same function off on his Android Lock jailbroken app. It shouldn't change the function of the home button, it would still pull the phone out of sleep mode but the app would launch just as any normal password protection would.
I am building GPS Tracking app. I want the tracking functionality to be started
after a reboot of device. Now I did with background compatibility, It works fine on background, but I need to start tracking when the device is rebooted (switch on) without having to open the app to start the functionality.
How can I implement that. Please give me procedure for how to enable the autostart for
that app and how to invoke a method to start tracking.
If you watch the app like skype and webEx that are autostarted on iphone starts..
How these apps are working. I have no idea for enabling this autostart.
Please suggest me how to do?
Thanks in advance...
Add the UIBackgroundModes key to your app’s Info.plist file. Set the value of this key to an array that includes the voip string.
You can do that in xcode: Select your project root -> Capabilities -> Background Modes -> check 'Voice over IP'.
From the documentation:
"An app with this key is also relaunched in the background immediately after system boot".
No third party app can be launched on startup. Skype (and others) simple respond to push notifiactions
The only way to actually open an app from the user not explicitly opening it, is to call a [[UIApplication sharedApplication] openURL]; - or somehow otherwise open a URL, and you have to set your app up to have a custom URL scheme... see this page.
E.g: Doodle jump has URLs such as doodlejump://highscores - which you can open from an email from them or their website.
The app responds to a custom URL, and correctly launches when in a suspended state. The question is, can I disable showing the Default.png when launched this way?
A use case for clarity:
app is started normally
a home button press puts app in standby
a url of the scheme the app recognizes is tapped in mobile safari
users sees Default.png before launch is complete.
As you probably know, when fast app switching activates usually the app is redisplayed with a screenshot of the last state rather than the Default.png. This is what I'd prefer happens when the URL launch takes place also.
It sounds like what is going on is that Fast App Switching is not actually working. So:
Make sure you are building the application for SDK for OS 4.0. If you don't, you app will not have fast app switching support.
See if fast app switching normally (otherwise) works with your application. I.E. when you just switch to safari, then re-launch your application, do you get the "default.png"?
Run the app under the debugger, but on your actual device. Make the problem happen, go into the Organizer, and look under device logs. This will show you if there was a low-memory issue which caused your application to be terminated, when Safari was launched, thus requiring it to be re-launched when the URL was selected.
I believe there were two mechanisms in place. In my app, I do not support "Launch with URL" - but what I do do is support the Application Delegate's call:
-(BOOL) application:(UIApplication *) application handleOpenURL:(NSURL *) url {
This may be the difference - this is the call which can be made to an application that is running to hand it a URL to process. If you are using the other technique, use this one instead. I use this, and do not see the "default.png" - i.e. do not evoke a "clean relaunch" when I get called.
Here's a possible workaround. This was causing me a headache with trying to seamlessly return from Facebook's single sign on process. I wanted the appearance of going back to my app's login area, instead of the appearance of restarting the app, even though I verified in every way possible that the app was indeed returning from fast app switching and not actually restarting.
While I couldn't find any way to force the app to display the previous state's screenshot, I did discover that the app will display Default-scheme.png (for example, Default-fb12345.png or Default-appname.png) when invoked with a url. So if your post-app switching screenshot is fairly predictable, grab a screenshot from iOS Simulator and copy it into your app. I would consider this an iOS bug. The app should always display the last screenshot when app switching, rather than Default-scheme.png simply because a url is involved.
Another possibility, which I didn't test, would be to symlink the bundle's Default-scheme.png (and Default-scheme#2x.png) to the snapshot file in the app home directory. This would be Library/Caches/Snapshots/[Bundle identifier]/UIApplicationAutomaticSnapshotDefault-Portrait#2x.jpg for most situations (unless it's landscape, or an iPad). If your app's state is unpredictable but the orientation is fixed, this could be a good option to try.
Make sure you've got the "Required Background Modes" key set in the Info.plist to the function that the app needs. If it's not listed, I just use "App Plays Audio" to keep it open.