# callback of register_push_notifications# see https://www.parse.com/tutorials/ios-push-notificationsdefapplication(application,didRegisterForRemoteNotificationsWithDeviceToken:newDeviceToken)# Store the deviceToken in the current installation and save it to Parse.currentInstallation=PFInstallation.currentInstallation()currentInstallation.setDeviceTokenFromData(newDeviceToken)currentInstallation.saveInBackground()end

Every Parse application installed on a device registered for push notifications has an associated Installation object. The Installation object is where you store all the data needed to target push notifications. For example, in a baseball app, you could store the teams a user is interested in to send updates about their performance.

classAppDelegatedefapplication(application,didFinishLaunchingWithOptions:launchOptions)self.register_push_notifications(application)self.configure_parse_service(launchOptions)@window=UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)@window.rootViewController=HelloViewController.new@window.makeKeyAndVisibletrueenddefapplication(application,didFailToRegisterForRemoteNotificationsWithError:error)if(error.code==3010)App.alert("Push notifications don't work in the simulator!")elseApp.alert("didFailToRegisterForRemoteNotificationsWithError: #{error.code}, #{error.domain}, #{error.userInfo}")endenddefregister_push_notifications(application)application.registerForRemoteNotificationTypes(UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound)enddefconfigure_parse_service(launchOptions)# see https://parse.com/apps/pushtest--177/edit#app_keysParse.setApplicationId("Parse.com の Application Id",clientKey:"Parse.com の client key",)PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)end# callback of register_push_notifications# see https://www.parse.com/tutorials/ios-push-notificationsdefapplication(application,didRegisterForRemoteNotificationsWithDeviceToken:newDeviceToken)# Store the deviceToken in the current installation and save it to Parse.currentInstallation=PFInstallation.currentInstallation()currentInstallation.setDeviceTokenFromData(newDeviceToken)currentInstallation.saveInBackground()enddefapplication(application,didReceiveRemoteNotification:userInfo)PFPush.handlePush(userInfo)endend