没有收到在iOS推送通知与Azure的通知Hub- didReceiveRemoteNotification不叫 [英] Not receiving push notification on iOS with Azure Notification Hub- didReceiveRemoteNotification is not called

查看:255
本文介绍了没有收到在iOS推送通知与Azure的通知Hub- didReceiveRemoteNotification不叫的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经按照这些通知中心资源,并在我的iOS设备上接收推送通知都没有成功。

I've followed these Notification Hub resources and have not been successful in receiving push notifications on my iOS device.

  • http://msdn.microsoft.com/library/jj927169.aspx
  • http://channel9.msdn.com/Blogs/Subscribe/Service-Bus-Notification-Hubs-Code-Walkthrough-iOS-Edition

我检查,复查,复查和我的设置:

I've checked, rechecked, and rechecked my setup:


  1. 创建一个新的通知中心:myhubname

  2. 照着所有的证书设置步骤。

  3. 在导出的证书私人,并上传到通知中心沙盒,以确保正确的APS网关用于

  4. 下载了提供的资料,它匹配的包ID为我的项目,自动检测到code签名和成功地编译。不要使用'V2D7FJQXP。 V2D7FJQXP.com.yourcompany.yourproject
  5. :这个字符串,在你的App ID显示出来,如果​​你想知道的
  6. 运行在物理设备 - 而不是在模拟器

  1. Created a new notification hub: myhubname
  2. Followed all the certificate provisioning steps.
  3. Exported the private cert and uploaded to Notification Hub under Sandbox to ensure correct APS gateway is used
  4. Downloaded the provisioning profile, which matches the bundle id for my project, auto detected for code signing, and compiles succesfully. Do NOT use the 'V2D7FJQXP.' of this string that shows up in your App ID if you are wondering: V2D7FJQXP.com.yourcompany.yourproject
  5. Running on physical device - not under simulator

一个演示应用程序时产生推送通知:

A demo application that is generating push notifications:

while (true)
{
    string connectionString = ServiceBusConnectionStringBuilder.CreateUsingSharedAccessSecretWithFullAccess("myhubname-ns", "…snip");
    var hubClient = NotificationHubClient.CreateClientFromConnectionString(connectionString, "myhubname");
    var iosPayload = AppleNotificationJsonBuilder.Create("Hello!");
    iosPayload.CustomFields.Add("inAppNotification", "Hello!");
    hubClient.SendAppleNativeNotification(iosPayload.ToJsonString());

    Console.WriteLine("Sent");

    Thread.Sleep(20000);
}

没有异常或问题产生。重整的命名空间,钥匙或集线器的名称会导致异常被抛出,并从​​Azure的提琴手响应code是2XX所以一切看起来很好。

No exceptions or issues are generated. Mangling any of the namespace, keys or hub names causes exceptions to be thrown, and fiddler response code from Azure is 2xx so all looks well.

我看到登记发生每正确低于code:

I see registration occur correctly per code below:


  • 我接受了设备上的推送通知

  • 我看到createDefaultRegistrationWithTags调用一次,然后看到存在是​​真实的,在后续调用。

  • 无来电didFailToRegisterForRemoteNotificationsWithError,这是确定

  • 在这里的code例如: http://msdn.microsoft.com/library /jj927168.aspx ,我已经取代某人://使用https://开头,因为它本来抛出。非问题,我想

  • I accepted push notifications on the device
  • I see the createDefaultRegistrationWithTags call once, then see that exists is true on subsequent calls.
  • No calls to didFailToRegisterForRemoteNotificationsWithError, which is OK
  • In the code example here: http://msdn.microsoft.com/library/jj927168.aspx, I have replaced sb:// with https://, as it would throw otherwise. Non-issue I'm thinking

-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *) deviceToken {
NSString* connectionString = [SBConnectionString stringWithEndpoint:@"https://gift-ns.servicebus.windows.net/" listenAccessSecret:@"…snip"];
self.hub = [[SBNotificationHub alloc] initWithConnectionString:connectionString notificationHubPath:@"gift-usw-dev"];
[self.hub refreshRegistrationsWithDeviceToken:deviceToken completion:^(NSError* error) {
    if (error == nil) {
        [self.hub defaultRegistrationExistsWithCompletion:^(BOOL exists, NSError* error2) {
            if (error2 == nil) {
                if (!exists) {
                    [self.hub createDefaultRegistrationWithTags:nil completion:^(NSError* error3) {
                        if (error3 != nil) {
                            NSLog(@"Error creating default registration: %@", error3);
                        }
                    }];
                }
            } else {
                NSLog(@"Error retrieving default registration: %@", error2);
            }
        }];
    } else {
        NSLog(@"Error refreshing device token: %@", error);
    }
}];
}

开始演示程序,然后运行该应用程序的iOS后,这里是我不知道如何有效地读出产生的仪表板。

After starting the demo app, then running the iOS application, here is the resultant dashboard which I have no idea how to read effectively.

考虑到我的证书是不正确的,或者有什么东西在Azure和APS之间丢失,我挖成故障排除的APS服务,并发现这一点:的 http://developer.apple.com/library/ios/#technotes/tn2265/_index.html 并跃升为部分的问题连接到推送服务

Thinking that my certificates were not correct, or something was lost between Azure and APS, I dug into troubleshooting the APS service and found this: http://developer.apple.com/library/ios/#technotes/tn2265/_index.html and jumped to the section Problems Connecting to the Push Service

和运行此命令:

的OpenSSL的s_client.First -connect gateway.sandbox.push.apple.com:2195 -cert YourSSLCertAndPrivateKey.pem -debug -showcerts -CAfile服务器的CA-cert.pem

但我没有一个.pem文件(OSX),所以我发现这个命令,让他们:

But I didn't have a .pem file (OSX), so I found this command to get them:

OpenSSL的PKCS12 -in keyStore.pfx退房手续keyStore.pem -nodes

在这里keyStore.pfx是从钥匙扣出口的推送通知证书中.P12的重命名版本。

where keyStore.pfx was the renamed version of the .p12 exported from the Keychain for the push notification cert.

该命令运行良好。这是怎么回事?

The command ran fine. What is happening?

推荐答案

该AppleNotificationJsonBuilder不使用最新的NuGet正确序列有效载荷的 Service Bus的preVIEW功能

The AppleNotificationJsonBuilder does not serialize the payload correctly using the latest nuget of Service Bus preview features.

所以,每个从MSDN说明的例子:

So, per the examples from msdn instructions:

var iosPayload = AppleNotificationJsonBuilder.Create("Hello!");
iosPayload.CustomFields.Add("inAppNotification", "Hello!");
Console.Log(iosPayload.ToJsonString());

生成:

{"aps":{"alert":"This is a test"},"inAppNotification":Hello! This is a test}

这是格式不正确。那么形成的串

Which is malformed. Well formed is "string"

{"aps":{"alert":"This is a test"},"inAppNotification":"Hello! This is a test"}

自定义负载每<罚款href=\"http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html\" rel=\"nofollow\">http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html

一个解决方案是微软使用Json.NET,或ping内部有人

One solution is to use Json.NET, or ping someone internally at Microsoft.

开放式问题:


  • 我怎么会监控网络流量关闭iOS设备?

  • 难道'JSON'到达的设备,但不正确地解析?或者是它在APS被杀?

  • 的Azure通知集线器仪表盘并没有多大帮助

希望这样可以节省别人的下午。

Hopefully this saves someone their afternoon.

这篇关于没有收到在iOS推送通知与Azure的通知Hub- didReceiveRemoteNotification不叫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆