php - 通知声音和角标(Badge)不起作用
<p><p>我创建了一个远程推送通知,通知效果很好,但是声音和角标(Badge)不起作用。在我的服务器端代码中,我有:</p>
<pre><code>$messageBody['aps'] = array('alert' => $message, 'sound' => 'default','badge' => 2);
</code></pre>
<p>这是 iOS 代码:</p>
<pre><code>func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
//print(error)
}
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
print(deviceToken)
}
func application(application: UIApplication, didReceiveRemoteNotificationuserInfo userInfo: ) {
print(userInfo)
}
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: ?) -> Bool
{
// Override point for customization after application launch.
application.registerForRemoteNotifications()
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: .Alert, categories: nil))
initLocationManager()
return true
}
</code></pre>
<p>为什么声音和角标(Badge)不起作用?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>php 代码看起来不错。在应用程序中,您是否注册了推送通知?还可以尝试卸载该应用,然后重新安装并接受该应用的声音和角标(Badge)。</p>
<p>编辑:同时在您的应用设置中启用声音和角标(Badge)。</p>
<p>编辑 2:试试这个:做:<code>let types:UIUserNotificationType = </code> 然后 <code>application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: types , categories: nil))</code> 您必须为应用程序注册警报、声音和角标(Badge),但您只注册了警报。</p></p>
<p style="font-size: 20px;">关于php - 通知声音和角标(Badge)不起作用,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/38567776/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/38567776/
</a>
</p>
页:
[1]