ios 在前端运行时收到一条通知怎么让他响铃

如题所述

第1个回答  2017-12-10
//前台得到的的通知对象
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler
{
// NSLog(@"notification.request:%@",notification.request);
// NSLog(@"notification.request.content:%@",notification.request.content);
NSDictionary * userInfo = notification.request.content.userInfo;
if([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]])
{
NSLog(@"userInfo1 -- %@",userInfo);

[JPUSHService handleRemoteNotification:userInfo];

}

// completionHandler(UNNotificationPresentationOptionAlert); // 需要执行这个方法,选择是否提醒用户,有Badge、Sound、Alert三种类型可以选择设置
completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert);

}
第2个回答  2015-03-23
要有推送证书,然后就可以接受推送了,具体可以到code4app中找例子
相似回答