Parse.com
- Cloud for apps
- Several services: Data, Push, Analytics...
- Push: Transaction initiated by the server (≠ Pull)
- Push SDK for iOS, Android, Windows and Windows Phone
-
Easy integration e.g. iOS (after having added the dependencies)
[Parse setApplicationId:@"xxxxx" clientKey:@"xxxxx"];
in application:didFinishLaunchingWithOptions:
// Register for Push Notitications, if running iOS 8
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
} else {
// Register for Push Notifications before iOS 8
[application registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound)];
}
in the App main delegate:
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// Store the deviceToken in the current installation and save it to Parse.
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation setDeviceTokenFromData:deviceToken];
[currentInstallation saveInBackground];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[PFPush handlePush:userInfo];
}
-
Subscribing to a channel
PFInstallation *currentInstallation = [PFInstallation currentInstallation]; [currentInstallation addUniqueObject:[NSString stringWithFormat:@"participant_uuid_%@", userUuid] forKey:@"channels"]; [currentInstallation saveInBackground];
-
Sending a push
Several API : JavaScript, PHP, .NET (including Unity SDK), REST API.
example:curl -X POST -H "X-Parse-Application-xxxxx" -H "X-Parse-REST-API-xxxxx" -H "Content-Type:application/json" -H "Cache-Control:no-cache" -H "Postman-Token:89afd163-f1e6-ac87-1399-0c14250b1989" -d '{"where": {"channels": {...}}' https://api.parse.com/1/push