Commit 981062b9 authored by Ryan Willoughby's avatar Ryan Willoughby
Browse files

add ios 8 preprocessor constraints

parent 108d34d0
Loading
Loading
Loading
Loading
+38 −14
Changes for src/ios/PushPlugin.m: 38 added lines, 14 removed lines.
Original line number Diff line number Diff line
@@ -49,7 +49,6 @@

    NSMutableDictionary* options = [command.arguments objectAtIndex:0];

    UIUserNotificationType UserNotificationTypes = UIUserNotificationTypeNone;
    UIRemoteNotificationType notificationTypes = UIRemoteNotificationTypeNone;
    
    id badgeArg = [options objectForKey:@"badge"];
@@ -60,41 +59,74 @@
    {
        if ([badgeArg isEqualToString:@"true"]) {
            notificationTypes |= UIRemoteNotificationTypeBadge;
            UserNotificationTypes |= UIUserNotificationTypeBadge;
        }
    }
    else if ([badgeArg boolValue]) {
        notificationTypes |= UIRemoteNotificationTypeBadge;
        UserNotificationTypes |= UIUserNotificationTypeBadge;
    }
    
    if ([soundArg isKindOfClass:[NSString class]])
    {
        if ([soundArg isEqualToString:@"true"]) {
            notificationTypes |= UIRemoteNotificationTypeSound;
            UserNotificationTypes |= UIUserNotificationTypeSound;
    }
    }
    else if ([soundArg boolValue]) {
        notificationTypes |= UIRemoteNotificationTypeSound;
        UserNotificationTypes |= UIUserNotificationTypeSound;
    }
    
    if ([alertArg isKindOfClass:[NSString class]])
    {
        if ([alertArg isEqualToString:@"true"]) {
            notificationTypes |= UIRemoteNotificationTypeAlert;
            UserNotificationTypes |= UIUserNotificationTypeAlert;
    }
    }
    else if ([alertArg boolValue]) {
        notificationTypes |= UIRemoteNotificationTypeAlert;
    }
    
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
    
    UIUserNotificationType UserNotificationTypes = UIUserNotificationTypeNone;
    
    if ([badgeArg isKindOfClass:[NSString class]])
    {
        if ([badgeArg isEqualToString:@"true"]) {
            UserNotificationTypes |= UIUserNotificationTypeBadge;
        }
    }
    else if ([badgeArg boolValue]) {
        UserNotificationTypes |= UIUserNotificationTypeBadge;
    }
    
    if ([soundArg isKindOfClass:[NSString class]])
    {
        if ([soundArg isEqualToString:@"true"]) {
            UserNotificationTypes |= UIUserNotificationTypeSound;
        }
    }
    else if ([soundArg boolValue]) {
        UserNotificationTypes |= UIUserNotificationTypeSound;
    }
    
    if ([alertArg isKindOfClass:[NSString class]])
    {
        if ([alertArg isEqualToString:@"true"]) {
            UserNotificationTypes |= UIUserNotificationTypeAlert;
        }
    }
    else if ([alertArg boolValue]) {
        UserNotificationTypes |= UIUserNotificationTypeAlert;
    }
    
    notificationTypes |= UIRemoteNotificationTypeNewsstandContentAvailability;
    UserNotificationTypes |= UIUserNotificationActivationModeBackground;
    
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UserNotificationTypes categories:nil];
    [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
    [[UIApplication sharedApplication] registerForRemoteNotifications];
#endif
    
    self.callback = [options objectForKey:@"ecb"];

    if (notificationTypes == UIRemoteNotificationTypeNone)
@@ -102,14 +134,6 @@

    isInline = NO;

    if ([[UIApplication sharedApplication]respondsToSelector:@selector(registerUserNotificationSettings:)]) {
        UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UserNotificationTypes categories:nil];
        [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
        [[UIApplication sharedApplication] registerForRemoteNotifications];
    } else {
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:notificationTypes];
    }
	
	if (notificationMessage)			// if there is a pending startup notification
		[self notificationReceived];	// go ahead and process it
}