我正在为ios使用
windows azure服务总线通知中心
SBNotificationHub* hub = [[SBNotificationHub alloc] initWithConnectionString: @"Endpoint=sb://......" notificationHubPath:@"...."]; NSMutableSet *set = [NSMutableSet set]; [set addobject:@"general"]; [hub registerNativeWithDevicetoken:devicetoken tags:[set copy] completion:^(NSError* error) { if (error != nil) { NSLog(@"Error registering for notifications: %@",error); [self.delegate homePopUpViewControllerEnterButtonPress:self]; } }];
var hubClient = NotificationHubClient.CreateClientFromConnectionString(<connection string>,"<notification hub name>"); IDictionary<string,string> properties = new Dictionary<string,string>(); properties.Add("badge","1"); properties.Add("alert","This is Test Text"); properties.Add("sound","bingbong.aiff"); hubClient.SendTemplateNotification(properties,"general");
我能够收到通知但我的问题是:通知没有我添加的任何属性,没有声音,没有徽章……
如果你能帮助我
参考文献:http://msdn.microsoft.com/en-US/library/jj927168.aspx
谢谢
解决方法
您注册了本机通知,但随后您正在发送模板通知.
如果您想发送本机(如果您想要访问不同平台上的设备,则需要额外的发送),您必须使用
如果您想发送本机(如果您想要访问不同平台上的设备,则需要额外的发送),您必须使用
hub.SendAppleNativeNotification( "{ \"aps\": { \"alert\": \"This is my alert message for iOS!\"}}","tag");
有关iOS有效载荷格式,请参阅https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html.
Nsstring* template = @"{aps: {alert: \"$(myToastProperty)\"}}"; [hub registerTemplateWithDevicetoken:devicetoken name:@"myToastRegistration" jsonBodyTemplate:template expiryTemplate:nil tags:nil completion:^(NSError* error) { if (error != nil) { NSLog(@"Error registering for notifications: %@",error); } }];
使用如下模板:
{ “aps”: { “alert”: “$(alert)” } }
然后,您可以像使用hub.SendTemplateNotification一样发送通知.
有关模板与本机之间差异的更多信息,请参阅:http://msdn.microsoft.com/en-us/library/jj927170.aspx
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。