Swift:推送通知didReceiveRemoteNotification不在后台调用

时间:2018-11-21 08:39:31

标签: swift notifications

我收到带有数据的推送通知,当我在应用程序中时,我会正确接收消息;当我在前台杀死应用程序时,我也会正确地接收消息,通知会通过didReceiveRemoteNotification传递,但是当应用程序在后台时,它将通过通过didReceive作为本地通知为何?

如果无法通过didReceiveRemoteNotification传递数据,那么当应用程序处于后台时如何从didReceive恢复数据?

这是发送的JSON:

{
  "data": {
    "title": "Callisthenics Workout: Bodyweight Training You Can Do Anywhere",
    "body": "Wherever you can swing your arms – whether that's in the park or at home",
    "fulltxt": "Bodyweight training has exploded during the last year or two, with more apps and videos being developed to help programme your training and show you how to progress your movements. Not only is this callisthenics workout a great way to shape up your body, but being able to control your own body in all different planes of movement is crucial for it to function at its peak, and stay healthy day to day.I tend to stay away from the term, 'functional training', because anything be functional if it serves a direct purpose. ",
    "author": "Simon Cushman",
    "created_at": "1534755892",
    "sheduled": "1542705780",
    "article_id": "3",
    "photo": "articles/NjXF9vIm3lZVa4VwZog1xbsJ4t7Pqk.jpg",
    "brand": "2",
    "fulltxt2": "The term is highly applicable here for most people, as functional training can build core strength and posture in a society that's been stuck to desk work and convenient travel for far too long. If you've ever seen someone try and do a handstand with poor posture and core, just doesn't work. So, here's a workout literally anybody can try out and either begin or progress on their way to the callisthenic glory.",
    "type": "article"
  },
  "notification": {
    "title": "Callisthenics Workout: Bodyweight Training You Can Do Anywhere",
    "body": "Wherever you can swing your arms – whether that's in the park or at home"
  }
}

我的问题:

  • 为什么在后台推送通知会通过didReceive而不是didReceiveRemoteNotification

  • 在后台运行应用程序时如何通过didReceiveRemoteNotification推送通知

  • 如果没有解决方案,并且强制推送通过didReceive,那么如何读取数据?

0 个答案:

没有答案
相关问题