Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Push Notification in ios

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 295
    Comment on it

    Here are the Push Notification Check for iOS8 and iOS7.

    iOS Push Notification Check

    #define IS_iOS8 [[[UIDevice currentDevice] systemVersion] floatValue] >= 8?YES:NO
    
    if (IS_iOS8) {
           UIUserNotificationType types = UIUserNotificationTypeSound | UIUserNotificationTypeBadge |                     UIUserNotificationTypeAlert;
                UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
                [[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
    }else{
             UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
              [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |    UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
    }
    

    Delegate Methods

    #ifdef __IPHONE_8_0
    - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
        [application registerForRemoteNotifications];
    
    }
    #endif
    
    #pragma marks- Device_Token
    // Getting Device Token and saving it
    - (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
    {
        _deviceToken = [[[[deviceToken description]
                          stringByReplacingOccurrencesOfString: @"<" withString: @""]
                         stringByReplacingOccurrencesOfString: @">" withString: @""]
                        stringByReplacingOccurrencesOfString: @" " withString: @""];
        NSLog(@"device token is : %@",_deviceToken);
    
        [self updateDeviceToken];
    }
    
    - (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
    {
        NSLog(@"Failed to get token, error: %@", error);
    }
    
    - (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo
    {
    
        NSString *info = [NSString stringWithFormat:@"%@",userInfo];
        NSLog(@"%@",info);
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: