提交 ec32b09b authored 作者: 史晓晨's avatar 史晓晨

feat:修改ios通知展示;

上级 414a7844
......@@ -178,7 +178,8 @@ userInfo fetchCompletionHandler
// 通知打开回执上报
[CloudPushSDK sendNotificationAck:extras];
NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
NSLog(@"Notification, date: %@, title: %@, subtitle: %@, body: %@, badge: %d, extras: %@.", noticeDate, title, subtitle, body, badge, extras);
NSLog(@"Notification, date: %@, title: %@, subtitle: %@, body: %@, badge: %d, extras: %@.",
noticeDate, title, subtitle, body, badge, extras);
if (title != nil) {
result[@"title"] = title;
}
......@@ -200,26 +201,27 @@ userInfo fetchCompletionHandler
if (isSendAck) {
[self.channel invokeMethod:@"onNotification" arguments:result];
} else {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)),
dispatch_get_main_queue(), ^{
[self.channel invokeMethod:@"onNotificationOpened" arguments:result];
});
}
}
-(NSString *)convertToJsonData:(NSDictionary *)dict{
- (NSString *)convertToJsonData:(NSDictionary *)dict {
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:&error];
NSString *jsonString;
if (!jsonData) {
NSLog(@"%@",error);
}else{
jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
NSLog(@"%@", error);
} else {
jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
NSMutableString *mutStr = [NSMutableString stringWithString:jsonString];
NSRange range = {0,jsonString.length};
NSRange range = {0, jsonString.length};
//去掉字符串中的空格
[mutStr replaceOccurrencesOfString:@" " withString:@"" options:NSLiteralSearch range:range];
NSRange range2 = {0,mutStr.length};
NSRange range2 = {0, mutStr.length};
//去掉字符串中的换行符
[mutStr replaceOccurrencesOfString:@"\n" withString:@"" options:NSLiteralSearch range:range2];
return mutStr;
......@@ -232,13 +234,15 @@ userInfo fetchCompletionHandler
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(
UNNotificationPresentationOptions))completionHandler {
// if(_showNoticeWhenForeground) {
// // 通知弹出,且带有声音、内容和角标
// completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge);
// } else {
// 处理iOS 10通知,并上报通知打开回执
[self handleiOS10Notification:notification isSendAck:YES];
// 通知不弹出
completionHandler(UNNotificationPresentationOptionNone);
// completionHandler(UNNotificationPresentationOptionNone);
// 通知弹出,且带有声音、内容和角标
completionHandler(
UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert |
UNNotificationPresentationOptionBadge);
// }
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论