iOS本地推送方法
UILocalNotification *notification = [[UILocalNotificationalloc]init];
notification.fireDate=[NSDatedateWithTimeIntervalSinceNow:10];
notification.timeZone=[NSTimeZonedefaultTimeZone];
notification.applicationIconBadgeNumber = 1;//设置右上角小圆圈数字为1
notification.soundName=UILocalNotificationDefaultSoundName;
notification.alertBody =@"推送测试";
[[UIApplicationsharedApplication] scheduleLocalNotification:notification];
注意:必须完成下面两步才可以看到效果
1.在工程中配置启动push Notification
2.在工程中的bundle identifier 必须完成apns的证书
提示:
1.打开系统设置去设置是否允许推送
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]]
2.
如果推送 APN 时,Badge number 被指定为0 ,则可能出现 APN 消息在通知中心被点击后,尽管调用了 [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]; 但 APN 消息在通知中心不会被删除的情况。 这种情况可以按如下代码调用以清除通知中心的 APN 通知。
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:1];
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];