我想实现推送到我的应用程序。Azure移动服务推不工作
不过,我使用的API,而不是数据的脚本,所以在我的API方法之一,我这样做:
var push = request.service.push;
push.apns.send(null, {
alert: "Alert",
payload: {
inAppMessage: "Hey, a new item arrived"
}
}, {
success: function(resp) {
console.log(resp)
},
error: function(err) {
console.error(err)
}
});
我日志显示这(所以我着陆在成功的方法[也知道,我不应该出现iOS的错误,由于苹果推服务器没有响应错误]):
{ isSuccessful: true,
statusCode: 201,
body: '',
headers:
{ 'transfer-encoding': 'chunked',
'content-type': 'application/xml; charset=utf-8',
server: 'Microsoft-HTTPAPI/2.0',
date: 'Mon, 20 Oct 2014 11:31:21 GMT' },
md5: undefined }
我的应用程序正确注册这样的,我看到了回调消息并且没有错误:
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken: (NSData *)deviceToken
{
[client.push registerNativeWithDeviceToken:deviceToken tags:@[@"uniqueTag"] completion:^(NSError *error)
{
NSLog(@"registerNativeWithDeviceToken callback");
if (error != nil)
{
NSLog(@"Error registering for notifications: %@", error);
}
}];
}
但在我的iphone没有推送消息的土地!什么都没有发生。
我试图检查我的Notification Hub中的错误,但我没有看到那里的日志。
我错过了什么?无论如何,我真的不明白我的实际设备ID是存储在服务器端的。我肯定错过了什么。
谢谢!
太棒了!当然这是一个凭证问题。现在正在工作。但是,我的“子问题”仍然存在:设备ID在哪里存储?我怎样才能将id绑定到我的数据库中的用户? – ullstrm 2014-10-21 07:01:24
以下博客解释标签:http://blogs.msdn.com/b/africaapps/archive/2013/10/22/windows-azure-notification-hubs-tags-and-creating-a-breaking-news-app .aspx我们建议使用标签进行用户标识和组标识。您可以在客户端或服务中添加标签。 – 2014-10-21 16:33:43
@Spoek对不起,我错过了你的回复!如果您正在使用节点移动服务,则可以通过门户添加注册脚本。如果您使用的是.Net移动服务,则可以使用以下说明添加INotificationHandler:http://blogs.msdn.com/b/azuremobile/archive/2014/04/08/push-notifications-using-notification-hub -and净backend.aspx。在不知道应用程序模式的情况下,我不能说将数据连接到后端数据的最佳位置,但我建议使用ZUMO InstallationID或用户令牌的UserID作为链接的关键标记而不是deviceId。 – 2014-11-13 21:56:35