该设备在iOS 8.1上运行
我正在使用xCode 6.1来编译应用程序.
这是注册推送的代码
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[application registerForRemoteNotifications];
}
else
{
[application registerForRemoteNotificationTypes: (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}
Run Code Online (Sandbox Code Playgroud)
它可以在应用程序向服务器注册时正常工作.
PEM文件也正确完成,因为我可以使用沙盒APN将推送发送到我的设备.
当我打印我的JSON有效负载时,didReceiveRemoteNotification我得到这个:
{
aps = {
alert = "Test Push Message";
};
}
Run Code Online (Sandbox Code Playgroud)
问题是当我收到推送时(即使设备设置为响亮)它也不会发出声音.
据我所知,如果你没有在JSON有效载荷中指定声音,它应该播放默认的OS声音.
在手机上的应用程序通知设置中,默认情况下启用声音,因为当我注册时,我指定了UIUserNotificationTypeSound.
其他人遇到过这个问题?
我希望实现与方法相同的功能stringWithFormat.
我想知道你是否可以打电话给我的另一个常数#define?
例如 [NSString stringWithFormat:@"If you enjoyed %@ would you mind please reviewing it?", appName];
我想要:
#define appName @"This App"
#define myMessage @"If you enjoyed **appName** would you mind please reviewing it?"
Run Code Online (Sandbox Code Playgroud)
谢谢