1
我正在構建iOS和Android應用程序(兩個應用程序)。 我正在尋找替代我不再信任的Urban Airship。主要是 ,因爲我看不到任何地方的價格。使用解析推送作爲獨立服務
我想使用Parse Push作爲獨立產品。這可能嗎? 我不想使用任何其他分析功能。
我正在構建iOS和Android應用程序(兩個應用程序)。 我正在尋找替代我不再信任的Urban Airship。主要是 ,因爲我看不到任何地方的價格。使用解析推送作爲獨立服務
我想使用Parse Push作爲獨立產品。這可能嗎? 我不想使用任何其他分析功能。
正如解析推送通知中解釋(iOS作業系統如Android)設置在https://parse.com/docs/push_guide#setup/iOS
是的,你可以。當然,您需要包含解析sdk,因爲您需要通過解析系統註冊設備。所以:
一旦註冊該設備用於接收推送通知(iOS的例子)
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
// Store the deviceToken in the current Installation and save it to Parse.
PFInstallation *deviceInstallation = [PFInstallation currentInstallation];
[deviceInstallation setDeviceTokenFromData:deviceToken];
// this will be used later for sending push notifcations to this device
[deviceInstallation setChannels:@[deviceToken]];
[deviceInstallation saveInBackground];
}
通過發送推送通知的iOS
PFPush *pushObj = [[PFPush alloc] init];
NSString* destDeviceToken = @"<DESTIONATION DEVICE TOKEN>";
// Through channels, you can uniquely identify devices or group of them for multicast
// push notification (imagine that more than one installation on your
// Parse database keep the same channel name).
// In this case we have set the channel name for each installation with the
// only unique deviceToken
[pushObj setChannels:@[destDeviceToken]];
// Push structure message
[pushObj setData:@{@"My Message!!",@"alert"}];
// send push (so, send to parse server that handle the push notification
// request and deliver it for you)
[pushObj sendPushInBackground];
通過發送推送通知的Android
String destDeviceToken = "<DESTIONATION DEVICE TOKEN>";
JSONObject data = new JSONObject("{\"alert\": \"My Message!!\"}");
ParsePush *push = new ParsePush();
push.setChannel(destDeviceToken);
push.setData(data);
push.sendPushInBackground();
通過的Javascript(雲代碼)發送推送通知 (它需要解析的雲代碼實現)
var destDeviceToken = '<DESTIONATION DEVICE TOKEN>';
Parse.Push.send({
channels: [ destDeviceToken ],
data: {
alert: "My Message!!"
}
}, {
success: function() {
// Push was successful
},
error: function(error) {
// Handle error
}
});
通過發送推送通知REST呼叫 (它允許你執行一個發送推送通知而不再在Parse上工作,所以從任何其他支持REST調用的平臺)
curl -X POST \
-H "X-Parse-Application-Id: <YOUR PARSE APP ID>" \
-H "X-Parse-REST-API-Key: <YOUR REST API KEY>" \
-H "Content-Type: application/json" \
-d '{
"channels": [
"<DESTIONATION DEVICE TOKEN>"
],
"data": {
"alert": "My Message!!",
}
}' \
https://api.parse.com/1/push
以這種方式,你不需要任何額外的實現,如註冊用戶或類似的東西。
希望它有幫助!