Function 'didFinishLaunchingWithOptions' getting invoked inappropriately - objective-c

I am using cordova 2.1.0 for my IOS app development.
I connected my IOS device to a MAC processor and installed/initialized my app running in xcode or dragged it from itunes folder. Now i physically disconnected my device from the processor and through wifi enabled in the device, sent notifications/messages through APNS to the device. I was able to successfully receive notifications in the device. Now after some time, i reconnected the device to the processor, which lead to a problem of the app launching again and calling 'didFinishLaunchingWithOptions' method again, which is not desirable as the launch/initialization should happen only once. This behaviour is random ie. every time when i disconnect/reconnect, it is not happening, only sometimes. Why is this happening. What could be the reason for this random behaviour.
Any help will be appreciated.Thanks

didFinishLaunchingWithOptions: is called every time the app is launched. When you run your app from Xcode, and disconnect the device, it kills the app. So, when you launch the app with the device disconnected, it starts the app again, which calls didFinishLaunchingWithOptions: when the app finishes launching. The same thing happens if you run the app from Xcode, and run it again the same way.
EDIT :
Not sure if it's clear, but didFinishLaunchingWithOptions: is not called if you quit the app (press the home button) and call it back without killing it.

Related

App crashes when receiving a VoIP call before unlocking after reboot

My app is using Linphone and PushKit to handle VoIP calls. It works well when the app is in the foreground, background, or suspended (killing app).
If we restart the phone and the app receives a VoIP call before the phone is unlocked (i.e. PIN is entered for the first time) then the app crashes - this is shown to the user when they unlock the phone. The crash only occurs in iOS 16 (and not with iOS 14).
Reboot -> make a VoIP call to the phone -> unlock -> crash. (iOS 16)
We've tested with other VoIP apps (e.g. Skype, Messenger); they do not crash but they do not notify the user that a call is received. There is just a notice that a call was missed when the phone is unlocked. We would like the same behaviour (i.e. do not crash, show a missed call).
What do we need to do to properly handle this use case?
Crash report:

WatchOS app keeps crashing when being opened from remote notification

WatchOS app works normally if being opened from home screen. If I try to open it from remote notification screen (by tapping title label) two app behaviors can be spotted:
If application was loaded previously (I don't know how to name it, maybe better to tell that app is not killed by system or still present in memory). In this case application will load normally and do some action if asked (for example open some Interface Controller and show remote notification details).
If application was launched long time ago (or killed by system, unloaded from memory, in my case I'm stopping it in Xcode). If app receives remote notification in this state after tapping on title label of notification scene it will try to load for some time and finally crash (this may take 1sec or 1min). Or it will stuck with loading indicator shown - what is interesting that in this case if I'll try to attach watch extension process to Xcode debug it will show that app is launched and works (for example I can send some data from parent iOS app and watchOS app will receive it - triggered method in Extension delegate and do some stuff).
Googling I have found that watch apps can be killed by system if they take to much power when being launched, so I tried to remove any load while app is starting itself but with no success - it still keeps crashing.
The only close to mine situation that I've found so far was a topic in apple developers forum:
https://forums.developer.apple.com/thread/20553
I have been spotting the same logs like in topic when watching how watch app behave in Xcode/Devices, but after updating to WatchOS 3 (now 3.1 beta) and using new Xcode 8 (now 8.1 beta) I can't see any logs from WatchOS at all (just some system messages that watch screen was turned of and on).
Have any one spotted such issues while working with watchOS remote notifications? Any suggestion where to search for solution?

Titanium iOS auto restart application in background once swiped off from background

I am working in an application that detects any Beacons nearby and gives and alert in the form of local notifications for iOS. I used TiBeacons library for titanium which did the work but I am right now stuck with an issue where I need to keep the Application running even when the user swipes off the application from background.
I was able to make it work in background which is the paused state,but is it possible to make it restart itself in the background when the user swipes the app from the background processes running,maybe with a delay if not promptly?? Thanks
There is no way to restart application after user removed it from a memory. This would be huge security bridge allowing developers to do lots of evil things to customers' devices.
You can run your code only when app is in foreground and background but never when it's killed.
You can try activate your app by receiving notification from Apple Notification Center Service:
The purpose of the Apple Notification Center Service (ANCS) is to give Bluetooth accessories (that connect to iOS devices through a Bluetooth low-energy link) a simple and convenient way to access many kinds of notifications that are generated on iOS devices.
The ability to detect iBeacons after the app was killed in the task switcher was only added in iOS 7.1. Also, I believe this functionality requires that beacon monitoring be set up with the app's main AppDelegate object as the CoreLocation delegate. I do not know much about Titanium, but glancing at the source, it appears it does not do this, and instead uses a different class as the CoreLocation delegate. This may explain why this does not work for you.
If my suspicion is true, you would not be able to detect after the app is killed using an unmodified version of that library.
Since I am not a Titanium expert, it would be best if someone who knows more about it could confirm or refute my suspicion.

ios launch appstore from within my app causes my app to terminate

I'm trying to take users of My App to the AppStore for several different functions - like Upgrade to Full Version, Rate/Review or simply View another App I've developed. However, all of these are causing my App to Terminate when iTunes is launched on the device. I'm using some simple code and
have tried many combinations of URLs, all of which successfully get to where they are going. Here are the behaviors:
User clicks Rate App
Code directs them to the web via:
[[UIApplication sharedApplication] openURL:
[NSURL URLWithString:[[MyApp defaultApp] itunesLink]]];
My App goes to the background, and my delegate's applicationDidEnterBackground is called successfully
As iTunes is coming up, my App is terminated. Happens whether I run via X-Code or on the device directly.
When I quit out of the store and look at the running processes on the device, my App is still shown there. I know it has been terminated from X-Code console, and when I try to restart it it starts fresh.
I've tried the itunesLink as either itms://itunes.apple.com/app/ or with http - all of which get to the correct end point. If I use www.google.com it works fine and my App is NOT terminated, just sent to the background and the website is displayed OK.
Other points are that when I run via the simulator, the openURL call returns failure and doesn't open any URL.
Any insights as to why my App would be terminating? It's acting like an iOS security feature or something which is shutting my App down, but I thought what I was doing was pretty standard stuff.
If anyone has seen anything similar, I'd really appreciate advice on the situation.
Your app could be terminated for a number of reasons. The best thing is to look at the device console using Xcode's Organizer:
Your app may simply be terminated as a result of low memory notifications. As soon as it moves to the background and the app store launches (iTunes and the app store both use plenty of memory) it can be killed to free up memory. In this case you will set messages from "jetsam" like this:
<Notice>: jetsam: kernel termination snapshot being created
<Warning>: Application 'UIKitApplication:com.yourapp[0x6337]' exited abnormally with signal 9: Killed: 9
You should use the Activity Monitor in Instruments to see how much memory your application is using. iOS will terminate the most memory-intensive applications first, so you should try to reduce your app's memory footprint.

how to show UIalertview while application is running but iphone is locked?

i want to show a alert when my app is running but phone is locked..we can say in power save mode. is there a way to show alertview without Push-Notification service when phone is idle and app is running.
If the application is locked, then your app is blocked. The only possibility (which I've never tried) might be to push a notification to the phone.