在后台问题苹果推送通知 [英] Apple Push Notification in Background Issue

查看:133
本文介绍了在后台问题苹果推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用parse.com作为我的APN供应商的测试程序,我要建。我已经证实了推送通知的工作,我已经能够成功地接收警报时,应用程序是在前台。另外,我在我的plist指定的 UIBackgroundModes 远程通知值。

在我的应用程序,我想收到推送通知时,向用户发送当前位置的数据传回我的应用程序特定的parse.com数据库。我并不真正关心的通知有效载荷本身,作为通知只是为了得到一个小片信息的一种手段。该应用程序是不断在后台收集数据并将其存储在一个持久的NSDictionary

我已经把在应用程序发送code中的位置:didReceiveRemoteNotification:方法。如果我的应用程序是在前台当我收到通知,该方法被调用。如果我的应用程序在后台,该方法不会被调用。


  • 难道我做错了什么?

  • 它甚至有可能执行的API请求应用程序:didReceiveRemoteNotification:当应用程序在后台与用户没有与通知**互动

编辑:问题仍然存在,即使当我使用应用程序:didReceiveRemoteNotification:fetchCompletionHandler:

注意:我的NSDictionary全位置数据是不是空的。另外,我不试图做任何UI操作在后台 - 只是想执行一个API请求


解决方案

检查以下内容:


  • 的通知有效载荷包括内容提供


  {警告:,
徽章:0
内容提供:1,
声音:}


I'm using parse.com as my APNs provider for a test app I'm building. I've confirmed that push notifications are working as I have been able to successfully receive alerts when the app is in the foreground. Also, I have the remote-notification value for the UIBackgroundModes key specified in my plist.

In my app, I'm wanting to send a user's current location data back to my app-specific parse.com database when a push notification is received. I don't actually care about the notification payload itself, as the notification is just a means to getting a small piece of info. The app is constantly collecting data in the background and storing it in a persistent NSDictionary.

I've put the location sending code in the application:didReceiveRemoteNotification: method. If my app is in the foreground when I receive a notification, the method gets called. If my app is in the background, the method isn't called.

  • Am I doing something wrong?
  • Is it even possible to execute an API request in application:didReceiveRemoteNotification: when the app is in the background and the user hasn't interacted with the notification?**

EDIT: The problem persists even when I use application:didReceiveRemoteNotification:fetchCompletionHandler:.

Note: My NSDictionary full of location data isn't empty. Also, I am not attempting to do any UI manipulation in the background - just trying to perform an API request.

解决方案

Check the following:

  • Notification payload includes "content-available"

{"alert":"",
"badge":"0",
"content-available":"1",
"sound":""}

这篇关于在后台问题苹果推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆