已收到 APNS 通知但未显示 [英] APNS notification received but not display
问题描述
我正在尝试实施推送通知.当应用处于运行状态时,我收到推送消息.
I am trying to implement pushnotification. I get pushed message when app is running state.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
NSLog(@"\n\n\n apns==%@\n\n\n",userInfo);
}
我的问题是当我在应用程序未运行时推送消息意味着徽章计数仅显示在应用程序图标上.它不会像关闭和查看按钮那样显示警报.即使我继续预测
my problem is when I pushed message when app is not running means badge count only show on the app icon. It will not display the alert like close and view buttons. Even I cont predict
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSLog(@"\n\n\n\apns==%@\n\n\n\n",launchOptions);
}
我还检查了设置 --> 通知 --> myApp --> 选择徽章、声音、警报
I checked also in settings --> Notifications --> myApp --> choose badges, sounds, alerts
我正在使用以下配置:
Mac 操作系统 10.9
Mac os 10.9
xcode 5.0.2
xcode 5.0.2
iOS 7.0
请给我建议.
我想要这条消息.
提前致谢.
推荐答案
您必须设置警报视图以显示您即将到来的推送通知消息,例如:
You have to setting Alert view for Displaying your coming Push notification Message like:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
if (application.applicationState == UIApplicationStateActive)
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"App Notification" message:[NSString stringWithFormat:@"%@",[[userInfo objectForKey:@"aps"] objectForKey:@"alert"]]delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
}
<小时>
当您的应用程序处于后台模式或关闭该管理器时,您将无法处理它.您必须从设备->设置中设置警报提示.并且您徽章显示因为您徽章的自动功能计数它是一个整数值,以便自动设置.只需从设备设置推送通知设置-->设置-->通知中心-->找到您的应用程序-->选择它并显示如下:
when your application in Background Mode or close then that manager by apple you can't handle it. you have to setting Alert prompt from device-->setting. And you badge Display because that automatically functionality of you badge count it's an integer value so that setting automatically. just set push notification setting from device--> setting-->Notification Center--->find your App--->select it and that display like:
更新:
您的推送通知有效负载 JSON 格式应如下所示:
Your push Notificaton Payload JSON formate should look like this:
{
"aps": {
"badge": 10,
"alert": "Hello world!",
"sound": "cat.caf"
}
}
这篇关于已收到 APNS 通知但未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!