Commit 720fb771 authored by Bob Easterday's avatar Bob Easterday
Browse files

Accept either Boolean or string argiuments to register method for iOS

parent 2d599878
Loading
Loading
Loading
Loading
+21 −3
Changes for src/ios/PushPlugin.m: 21 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -56,14 +56,32 @@
	self.callbackId = [arguments pop];

    UIRemoteNotificationType notificationTypes = UIRemoteNotificationTypeNone;
    id badgeArg = [options objectForKey:@"badge"];
    id soundArg = [options objectForKey:@"sound"];
    id alertArg = [options objectForKey:@"alert"];
    
    if ([[options objectForKey:@"badge"] isEqualToString:@"true"])
    if ([badgeArg isKindOfClass:[NSString class]])
    {
        if ([badgeArg isEqualToString:@"true"])
            notificationTypes |= UIRemoteNotificationTypeBadge;
    }
    else if ([badgeArg boolValue])
        notificationTypes |= UIRemoteNotificationTypeBadge;
    
    if ([[options objectForKey:@"sound"] isEqualToString:@"true"])
    if ([soundArg isKindOfClass:[NSString class]])
    {
        if ([soundArg isEqualToString:@"true"])
            notificationTypes |= UIRemoteNotificationTypeSound;
    }
    else if ([soundArg boolValue])
        notificationTypes |= UIRemoteNotificationTypeSound;
    
    if ([[options objectForKey:@"alert"] isEqualToString:@"true"])
    if ([alertArg isKindOfClass:[NSString class]])
    {
        if ([alertArg isEqualToString:@"true"])
            notificationTypes |= UIRemoteNotificationTypeAlert;
    }
    else if ([alertArg boolValue])
        notificationTypes |= UIRemoteNotificationTypeAlert;
    
    self.callback = [options objectForKey:@"ecb"];