2013-08-05 159 views
2

我試圖按照tutorial,發出推送通知:無法發送推送通知

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不再受支持。

回答

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();