iOS 8 设备上没有 Xcode 的无提示通知问题 [英] Silent Notification Issues without Xcode on iOS 8 Devices

查看:22
本文介绍了iOS 8 设备上没有 Xcode 的无提示通知问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在测试自 iOS 7 起可用的静音通知功能.

I've been testing out the Silent Notification feature that is available since iOS 7.

我的应用程序面向 iOS 7 和 UP.

My application is targeting iOS 7 and UP.

我正在 iPhone6 设备上进行测试.

I'm testing on an iPhone6 device.

当我的 iPhone 连接到计算机时,我的应用程序似乎一切正常Xcode 正在运行应用程序.所有无提示通知都 100% 有效,它们也会显示在我的应用程序中.

Everything seems to work great in my application when my iPhone is connected to the computer & Xcode is running the application. All silent notifications work 100% and they show up in my application as well.

但是,如果我停止 Xcode &发送无声通知——我的设备根本没有收到无声通知.

However, if I stop Xcode & send a silent notification -- my device does not receive the silent notifications at all.

我做了很多研究,但没有任何东西给我答案,也没有帮助我确定发生了什么.

I have done a LOT of research but nothing has given me an answer nor has helped me determine what is going on.

我没有终止我的应用程序.所以,这不是问题.您仍然可以在应用切换器中看到该应用.

I have not killed my application. So, that is not the issue. You can still see the application in the app switcher.

我的应用程序确实会收到定期推送通知(使用和不使用 Xcode).问题在于静默通知.

My application does receive regular push notifications (with and without Xcode). The issue is with Silent Notifications.

找到了这些(但它们没有帮助我解决问题):

Found these (but they did not help me solve the issue):

  1. IOS 8 静默推送通知在没有 Xcode 的情况下无法工作
  2. iOS 静默推送通知仅在连接到代码

我也将Priority"标签添加到了我的 JSON 负载中……但仍然没有运气.

I have added the "Priority" tag to my JSON payload as well... and still no luck.

这是我的有效载荷:

$body['aps'] = array('内容可用' =>1、'警报' =>$消息,'优先级' =>10、'声音' =>'默认');

我什至尝试过所有小写的优先级".

I've even tried "priority" all lower-cased.

我的手机收到警报并发出声音.但是,如果用户选择应用程序图标"而不是横幅警报——它不会收到静默通知.这仅在我的应用程序未连接并从 Xcode 运行时发生.

My phone does get the alert and it makes the sound. But, if a user selects the "app icon" instead of the banner alert -- it doesn't get the silent notification. This only happens when my application isn't connected and running from Xcode.

此外,我使用的是开发者证书和配置文件.

Also, I am using a Developer certificate and Provisioning Profile.

更新 1:

发现优先级设置应该是二进制通知的一部分,而不是 APNS 有效负载.

Found out that the Priority setting is supposed to be apart of the binary notification not the APNS Payload.

我从有效负载中删除了优先级"并将二进制通知配置为命令 2.

I removed "priority" from payload and configured binary notification as Command 2.

参见:https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html

使用 Xcode 测试.一切正常.没有 Xcode 测试.还是一样的问题.=(

Tested with Xcode. Everything works. Tested without Xcode. Still same issue. =(

更新 2

我在 iPhone 4 设备上测试了该应用程序.Silent Notifications 可以使用或不使用 Xcode.所以,这一定是 iOS 8 设备的问题.

I tested the application on an iPhone 4 Device. Silent Notifications work with or without Xcode on it. So, this must be an issue strictly with iOS 8 devices.

更新标题以仅反映 iOS 8.我不确定如何为 iOS 8 设备解决此问题.有人有什么建议吗?

Updating title to reflect only iOS 8. I'm not sure how to fix this for iOS 8 devices. Anyone have any suggestions?

推荐答案

好的,我终于解决了为什么在 iOS 8 设备上无法使用静默通知的原因.

Okay, so I finally solved why the silent notification wasn't working on iOS 8 devices.

在您从 PHP 脚本发送的二进制通知中,优先级必须设置为 5.当您不是从 Xcode 运行应用程序时,它不会与 10 一起使用.

In the binary notification that you send from the PHP script, the priority must be set to 5. It will not work with a 10 when you are not running your application from Xcode.

我不知道为什么应用程序在从 Xcode 运行时使用 10 —— 这就是为什么很难确定哪里出了问题.我也不知道为什么优先级为 10 对 iOS 7 设备有效.

I don't know why the application worked with a 10 when running from Xcode -- this is why it was so hard to determine what was wrong. I also don't know why a priority of 10 worked for iOS 7 devices.

参见:https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html

这篇关于iOS 8 设备上没有 Xcode 的无提示通知问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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