Last active
August 29, 2015 13:56
-
-
Save Aquima/8915344 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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