Bladeren bron

Fixes #731 Prevent crash when user info is nil

Sebastián Katzer 10 jaren geleden
bovenliggende
commit
9ac02bdcfc
2 gewijzigde bestanden met toevoegingen van 5 en 2 verwijderingen
  1. 1 1
      src/ios/APPLocalNotification.m
  2. 4 1
      src/ios/UILocalNotification+APPLocalNotification.m

+ 1 - 1
src/ios/APPLocalNotification.m

@@ -571,7 +571,7 @@
 {
     UILocalNotification* notification = [localNotification object];
 
-    if ([notification wasUpdated])
+    if ([notification userInfo] == NULL || [notification wasUpdated] )
         return;
 
     NSTimeInterval timeInterval = [notification timeIntervalSinceLastTrigger];

+ 4 - 1
src/ios/UILocalNotification+APPLocalNotification.m

@@ -168,9 +168,12 @@ NSInteger const APPLocalNotificationTypeTriggered = 2;
 
     [obj removeObjectForKey:@"updatedAt"];
 
+    if (obj == NULL || obj.count == 0)
+        return json;
+
     data = [NSJSONSerialization dataWithJSONObject:obj
                                            options:NSJSONWritingPrettyPrinted
-                                             error:Nil];
+                                             error:NULL];
 
     json = [[NSString alloc] initWithData:data
                                  encoding:NSUTF8StringEncoding];