2

我正在尝试按照教程发送推送通知:

var hubClient = NotificationHubClient.CreateClientFromConnectionString("Endpoint=sb://xxx-ns.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=xxx=", "xxxapp");
                hubClient.SendGcmNativeNotificationAsync("{ \"data\" : {\"msg\":\"Hello from Windows Azure!\"}}", "xxxapp");
            }

但我没有得到回应?不再支持 SendGcmNativeNotification。

4

1 回答 1

1

SendGcmNativeNotification 在 Service Bus SDK 2.1 中被标记为内部。至于您的问题, SendGcmNativeNotificationAsync() 不会返回实际结果,而是返回一个任务。以下是如何使用 c# 5 语法使用它的示例:

private static async Task<NotificationOutcomeState> CallNotificationHub()
{
    var hubClient = NotificationHubClient.CreateClientFromConnectionString(
                "<your connection string with full access>",
                "<your notification hub name>");
    var outcome = await hubClient.SendGcmNativeNotificationAsync(
                        "{ \"data\" : {\"msg\":\"Hello from Windows Azure!\"}}");
    return outcome.State;
}

CallNotificationHub().Wait();
于 2013-08-06T02:20:47.830 回答