有没有办法使用google的firebase发送静音APNS?似乎如果应用程序在后台,它将始终向用户显示通知.
谢谢?
push-notification apple-push-notifications firebase silentpush firebase-cloud-messaging
我希望iOS11版本能解决无声推送问题,这是最新的测试版和通用版iOS版.
目前我很难理解,为什么我没有收到任何静音推送消息,这实际上应该唤醒我的应用程序以在后台执行一些所需的任务.
在iOS 10中,我只使用后台获取功能,并在我的AppDelegate中实现了"唤醒代码",如下面的代码所示.
在iOS 11中,注册代码仍然正常工作,我的后端也向Apples DEV服务器(沙箱)和PROD服务器(生产版本)提供推送通知.不幸的func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)
是,静音推送通知从不调用该函数.
我真的错过了iOS 11的东西吗?
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
// .. some variables here ...
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// register silent push notification in backend
application.registerForRemoteNotifications()
// ... some code here ...
// Set Background Fetch Intervall for background services / terminated app
UIApplication.shared.setMinimumBackgroundFetchInterval(UIApplicationBackgroundFetchIntervalMinimum)
// ... some code here ... …
Run Code Online (Sandbox Code Playgroud) 我试图Silent Push Notification
在我的应用程序中定期实现,即每天一次将数据上传到服务器.
但是在iOS 11.2.6上,它始终无法调用委托方法
-(void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))
Run Code Online (Sandbox Code Playgroud)
completionHandler
无声推送通知.
在设备日志中,我可以看到收到了静默推送通知,但是应用程序启动被取消DuetActivitySchedulerDaemon
(根据日志).
你能帮我解决一下这个问题吗?以下是设备的日志.
Apr 11 21:44:59 iPhone- SpringBoard(UserNotificationsServer)[2696] <Notice>: [com.***.***-myapp] Received remote notification request 91E8-DC24 [ hasAlertContent: 0, hasSound: 0 hasBadge: 0 hasContentAvailable: 1 hasMutableContent: 0 ]
Apr 11 21:44:59 iPhone- SpringBoard(UserNotificationsServer)[2696] <Notice>: [com.***.***-myapp] Deliver push notification request 91E8-DC24.
Apr 11 21:44:59 iPhone- SpringBoard(UserNotificationsServer)[2696] <Notice>: [com.***.***-myapp] Passing content-available push to Duet.
Apr 11 21:44:59 iPhone- SpringBoard(DuetActivityScheduler)[2696] <Notice>: SUBMITTING: <private>.
Apr 11 …
Run Code Online (Sandbox Code Playgroud) 我不知道这是苹果的错误还是功能。在文档中:
如果用户强制退出,系统不会自动启动您的应用程序。在这种情况下,用户必须重新启动您的应用程序或重新启动设备,然后系统才会尝试再次自动启动您的应用程序。
至于其他StackOverflow的问题是有这个 这个显示相同。
在我的情况下,系统在后台重新启动应用程序并运行用于存储在数据库中的代码。怎么可能呢?它调用方法 didFinishLaunchingWithOptions: 然后didReceiveRemoteNotification:
在后台(未显示在应用程序切换器中)。但是在早期版本中,它不会唤醒在 iOS 12.2 中测试的后台应用程序
我正在发送有效载荷以进行通知
"aps": {
"alert": {
"body": "",
"title": ""
},
"mutable-content": 0,
"category": "",
"badge": "",
"sound": "",
"content-available": 1
},
"data": {
//other fields
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用 PushKit 和 CallKit 开发 VoIP 应用程序。我知道类似的问题在不同的论坛上经常被问到,但不幸的是从未得到真正的回答。此外,这些帖子中的大多数都是 2015 年左右的,所以我认为很可能已经发生了很多变化,因为有人可能同时想到了如何让这个工作发挥作用。
当应用程序在前台运行或发送到后台时,它也会使用沙箱服务器以及生产服务器接收推送通知。
我使用的是 iOS 11 和 Xcode 9,需要在“功能”中启用常规推送通知,以及手动将 voip 后台模式添加到 info.plist 以便调用委托方法。仅链接 CallKit 和 PushKit 不足以接收通知。我还启用了后台音频、后台获取和远程通知。我还在进行推送注册表注册之前创建了一个后台任务,并在收到推送令牌后结束该任务。
重启后唤醒应用程序或来电时强制退出。
我看到在仪器活动监视器中的来电上启动了该进程,但看起来有些东西无法正常工作,因为我没有收到来电用户界面。
-pushRegistry:didReceiveIncomingPushWithPayload:forType:
或者也许(仅)-application:didFinishLaunchingWithOptions:
?更新:
我自己想出了一个解决方案。这更多的是客户端和服务器之间的时间问题。所以这对我有用。
同样重要的是不要过早调用推送通知委托上的完成处理程序,这将使应用程序重新进入睡眠状态并且永远不会收到 INVITE。
也可能有帮助,并且可以让场景变得更加宽容。如果您的 sip 服务器多次发送邀请,请确保每次都使用最新的注册信息。意思是……假设第一个 INVITE 发送得太早,导致某些过时的注册信息,并且客户端仍然尝试在服务器上更新该信息……确保下一个 INVITE 使用更新的信息。某些 sip 服务器仅使用每次迭代可用的第一个信息。所以你会永远等待而没有收到客户端的任何信息。
使用 Xcode 13.0、iOS 15 SDK 构建应用程序时,iOS 15 设备中未收到 APNS 内容可用推送。
推送有效负载数据,内容可用:1 不工作
{"aps":{"content-available":1},"update":"2|1"}
Run Code Online (Sandbox Code Playgroud)
但通知消息推送正常
{"aps":{"alert":"welcome"}}
Run Code Online (Sandbox Code Playgroud)
iOS 15静默推送消息的标头字段中是否有任何有效负载或配置?
payload apple-push-notifications silentpush silent-notification ios15