application didReceiveRemoteNotification not called in particular occasion - objective-c

I am writing an app which will receive remote notifications sent from Firebase.
It works perfectly fine when I first install the app on an iPhone, the notification can be received no matter the app is in background or foreground.
However, when I killed the app and restarted it, then press home button again to send it to background, the app can no longer receive notifications in background state, and can only receive on foreground.
Please help. Thanks in advance!

Related

React native Fire base Push notification not working in OPO,VIVO, MI when app is close

Fire base push notification is not working when app Killed or force stop in Mi, Vivo, OPPO.In my code, android firebase push notification is working fine in Moto g4 and Samsung, but it's not working in Mi, Vivo, OPPO when app is killed. But it's working when autoStart on. That means the background service killed if the app is autostart off. How can I solve this issue?
I already tried like following link oppo, vivo app kill notification not coming in android fcm. But it opens the settings and user needs to switch on option. However, I need automatically on that.

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?

What happens when the user hits the home button?

I have an app which can currently communicate with an server.
Imagine the following case:
User hits some buttons which triggers an server request.
The request is send to the server and is processed.
The user hits the home button (and maybe removes the app from the
memory by hitting the home button two times).
The script is done processing and returns it result.
Question: Will the device from the user gets this response (I am pretty sure it will not when removing from memory, but what when just closing the app)?
There are 5 active states in iOS:
Not running: The app has not been launched or was running but was
terminated by the system.
Inactive: The app is running in the foreground, but not receiving
events. An iOS app can be placed into an inactive state, for
example, when a call or SMS message is received.
Active: The app is running in the foreground, and receiving
events.
Background: The app is running in the background, and executing
code.
Suspended: The app is in the background, but no code is being
executed.
On your third scenario where the user hits the home button, the app will be sent into the Background state, #4, and can still receive data and allow your script to run. If the user kills the app, (state #1) your script will not complete running.
So, to answer your question, yes your app will continue executing code if the user places it in the Background state, but not if they close the app because that will put your app in the Not Running state.
Application is suspended (on the background, not running) - In this case the execution of you requests get paused. When your app gets to the foreground, usually the requests end with a timeout.
Application is terminated - in this case the context of your application is lost and after restarting there are no running requests.
That's the 2 cases you should be concerned about. For me it a good solution to cancel all running requests when the application is entering background because it is easier to restart everything when the app gets to foreground again.
Also, you can setup background mode and that enables the app to perform some code when on the background but that's a more advanced topic.

Function 'didFinishLaunchingWithOptions' getting invoked inappropriately

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.

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.