Difference behaviour of didReceiveRemoteNotification between APNS production and development environment
Asked Answered
S

1

26

I have noticed a different behavior of didReceiveRemoteNotification between APNS production and development environment.

In development mode (build using development provisioning profile) this method is being called when user taps on notification. In both background and active state.

but in production mode (build using adhoc provisioning profile) this method is being called when user taps on notification if app is in background or not active but when the app is in active state this method calls immediatily when receive notification.

Can anyone help me to understand this different behavior?

I want my user to redirect to a different screen when he taps on notification (in active state), but due to this behavior he is automatically redirecting to other screen.

Siblee answered 4/9, 2017 at 9:53 Comment(5)
Please refer this: #43802458Task
@JitendraSolanki my question is different, and same issue with your suggested method, calling immediatily when receive notification.Siblee
@MayankJain please refer to my answer. tell me if I'm wrong somewhere.Phanotron
With background what do you mean, killed or just in the background?Spadix
@AkshaySunderwani just background also same behavior with killed, but different in case of foregroundSiblee
W
-1

Your question make me confuesed and I did a test,"In development mode (build using development provisioning profile) this method is being called when user taps on notification. In both background and active state."The Documentation of WatchKit says:If a remote notification arrives while your app is active, WatchKit calls this method to deliver the notification payload. Use this method to respond to the notification(whithout your tap).I tested it on my iphone,the result is the same,it's run without my tap.And it's deprecated in iOS 10.enter image description here

Woof answered 14/9, 2017 at 10:9 Comment(3)
Please read my question again "In production mode (build using adhoc provisioning profile) this method is being called when user taps on notification if app is in background or not active but """""when the app is in active state this method calls immediatily when receive notification."""""Siblee
What I mean is there's no difference between the two modes,when the app is in active state this method calls immediatily when receive notification,whether it's in development mode,or in production mode.Maybe you've overlooked something else.Woof
You can achieve your needs through the following two methods. - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler { completionHandler(UNNotificationPresentationOptionSound); }.And do your response in this method -(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler;Woof

© 2022 - 2024 — McMap. All rights reserved.