Skip to content

Instantly share code, notes, and snippets.

@Aquima
Last active August 29, 2015 13:56
Show Gist options
  • Save Aquima/8915344 to your computer and use it in GitHub Desktop.
Save Aquima/8915344 to your computer and use it in GitHub Desktop.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound];
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSString* deviceTokens = [[[[deviceToken description]
stringByReplacingOccurrencesOfString: @"<" withString: @""]
stringByReplacingOccurrencesOfString: @">" withString: @""]
stringByReplacingOccurrencesOfString: @" " withString: @""] ;
NSLog(@"%@",deviceTokens);
// PFInstallation *currentInstallation = [PFInstallation currentInstallation];
// [currentInstallation setDeviceTokenFromData:deviceToken];
// currentInstallation.channels = @[@"global"];
// [currentInstallation saveInBackground];
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
if (error.code == 3010) {
NSLog(@"Push notifications are not supported in the iOS Simulator.");
} else {
// show some alert or otherwise handle the failure to register.
NSLog(@"application:didFailToRegisterForRemoteNotificationsWithError: %@", error);
}
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
// [PFPush handlePush:userInfo];
NSLog(@"Received notification: %@", userInfo);
UIApplicationState state = [application applicationState];
if (state == UIApplicationStateActive) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Notification"
message:@"llego"
delegate:self cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment