Conditionally dismiss remote notification from didReceiveRemoteNotification

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 09:35:35

问题


My target is to run iOS app in background by receiving silent-pushes and post UILocalNotifications with some data downloaded from internet and decrypted inside app. I did it using method didReceiveRemoteNotification:fetchCompletionHandler: and pushing empty silent notifications from my server when some data is available to client.

But if user force closes app - this method is not called at all. And user is not notified about something available for him.

Then I added some text to push notification. So some time it all works as I want, but several hours later it become to show 2 notifications for 1 event. First - visible but not sensitive notification from server and local notification with sensitive data.

I just wanna always download data by push and show local notification and when my app is force closed - show just a notification that "something" happens.

UPDATE:

Looks like my question is closely related to Will iOS launch my app into the background if it was force-quit by the user?

The most strange thing is that: I did wanted behavior and it works for several hours. I don't know how exactly I achieved this, but here are my screenshots, where app was suspended and also was manually killed from switcher:

I think it can be some kind of trick with this: https://stackoverflow.com/a/8749035/440168 Because my code changed app badge. But may be this was an apple bug that it happens...

来源:https://stackoverflow.com/questions/26499116/conditionally-dismiss-remote-notification-from-didreceiveremotenotification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!