@@ -384,21 +384,31 @@ - (void)handeleApnsCallback:(NSDictionary *)userInfo type:(NSString *)type {
384384- (NSDictionary *)convertApnsMessage : (NSDictionary *)userInfo type : (NSString *)type {
385385 NSMutableDictionary *extras = [NSMutableDictionary dictionary ];
386386 for (NSString *key in userInfo.allKeys ) {
387- if ([key isEqualToString: @" _j_business" ] || [key isEqualToString: @" _j_msgid" ] || [key isEqualToString: @" _j_uid" ] || [key isEqualToString: @" aps" ] || [key isEqualToString: @" _j_geofence" ] || [key isEqualToString: @" _j_extras" ] || [key isEqualToString: @" _j_ad_content" ]) {
387+ if ([key isEqualToString: @" _j_business" ] || [key isEqualToString: @" _j_msgid" ] || [key isEqualToString: @" _j_uid" ] || [key isEqualToString: @" aps" ] || [key isEqualToString: @" _j_geofence" ] || [key isEqualToString: @" _j_extras" ] || [key isEqualToString: @" _j_ad_content" ] || [key isEqualToString: @" _j_data_ " ] ) {
388388 continue ;
389389 }
390390 [extras setValue: userInfo[key] forKey: key];
391391 }
392392
393- NSString *title = userInfo[@" aps" ][@" alert" ][@" title" ];
394- NSString *content = userInfo[@" aps" ][@" alert" ][@" body" ];
395- NSString *badge = userInfo[@" aps" ][@" badge" ];
396- NSString *sound = userInfo[@" aps" ][@" sound" ];
397- if (userInfo[@" _j_extras" ]) {
398- title = userInfo[@" _j_extras" ][@" alert" ][@" title" ];
399- content = userInfo[@" _j_extras" ][@" alert" ][@" body" ];
393+ id alertData = userInfo[@" aps" ][@" alert" ];
394+ NSString *badge = userInfo[@" aps" ][@" badge" ]?[userInfo[@" aps" ][@" badge" ] stringValue ]:@" " ;
395+ NSString *sound = userInfo[@" aps" ][@" sound" ]?userInfo[@" aps" ][@" sound" ]:@" " ;
396+ NSString *title = @" " ;
397+ NSString *content = @" " ;
398+ if ([alertData isKindOfClass: [NSString class ]]){
399+ content = alertData;
400+ }else if ([alertData isKindOfClass: [NSDictionary class ]]){
401+ title = alertData[@" title" ]?alertData[@" title" ]:@" " ;
402+ content = alertData[@" body" ]?alertData[@" body" ]:@" " ;
403+ }
404+
405+ if (userInfo[@" _j_extras" ] && [userInfo[@" _j_extras" ] isKindOfClass: [NSDictionary class ]]) {
400406 badge = userInfo[@" _j_extras" ][@" badge" ];
401407 sound = userInfo[@" _j_extras" ][@" sound" ];
408+ if ([userInfo[@" _j_extras" ][@" alert" ] isKindOfClass: [NSDictionary class ]]) {
409+ title = userInfo[@" _j_extras" ][@" alert" ][@" title" ];
410+ content = userInfo[@" _j_extras" ][@" alert" ][@" body" ];
411+ }
402412 }
403413
404414 NSMutableDictionary *temResult = [NSMutableDictionary dictionaryWithDictionary: @{
@@ -420,7 +430,10 @@ - (NSDictionary *)convertApnsMessage:(NSDictionary *)userInfo type:(NSString *)t
420430// 处理本地通知回调
421431- (void )handlerLocalNotiCallback : (NSDictionary *)userInfo type : (NSString *)type {
422432
423- NSMutableDictionary *result = [NSMutableDictionary dictionaryWithDictionary: userInfo];
433+ NSMutableDictionary *result = [NSMutableDictionary dictionary ];
434+ if (userInfo && [userInfo isKindOfClass: [NSDictionary class ]]) {
435+ result = [NSMutableDictionary dictionaryWithDictionary: userInfo];
436+ }
424437 [result setValue: type forKey: NOTIFICATION_EVENTTYPE];
425438 if ([JPushStore shared ].localNotiCallback ) {
426439 [JPushStore shared ].localNotiCallback (result, YES );
0 commit comments