2011-05-09 53 views
1

我正在建設和iPhone應用程序使用推送通知,一切都好。但現在我要用ASP.net構建服務器端。任何人都可以幫助我...因爲我厭倦了使用谷歌的解決方案,但不幸的是我沒有找到任何東西。apns and asp.net

....

注:我試過這個鏈接http://arashnorouzi.wordpress.com/2011/03/31/sending-apple-push-notifications-in-asp-net-part-1/

,但尚未

+0

您已經看過[part 2](http://arashnorouzi.wordpress.com/2011/04/01/sending-apple-push-notifications-in-as-p-net-%e2%80%93-part -2-generating-apns-certificates /)和[part 3](http://arashnorouzi.wordpress.com/2011/04/13/sending-apple-push-notifications-in-asp-net-%e2%80 %93-part-3-apns-certificates-registration-on-windows /)?第4部分將討論[apns-sharp library](http://code.google.com/p/apns-sharp/) - 你在使用它嗎?如果你是這樣,你可能想標記你的問題[apns-sharp](http://stackoverflow.com/questions/tagged/apns-sharp)。你嘗試過那裏的樣品嗎? – Rup 2011-05-09 08:44:49

+0

不,我不想使用apns-sharp,但不幸的是這是我發現使用.net的唯一庫。我已閱讀第一部分和第二部分和第三部分(所有這部分不包含任何.net開發示例),你有什麼想法,......關於 – 2011-05-09 09:30:39

+0

行;我鼓勵你重新考慮使用apns-sharp,因爲它可以自由使用(Apache 2許可證),並且它已經被開發和測試。如果不是的話,你可能會從閱讀我認爲的來源中學習。你爲什麼不想用它?不,我沒有任何經驗,我自己很抱歉。 – Rup 2011-05-09 10:16:14

回答

1

沒有完成工作後,天職。我選擇了與Urbanairship它提供了一個完整的推送服務器的工作:

Dim request As WebRequest = WebRequest.Create("https://go.urbanairship.com/api/push/broadcast/") 
Dim postData As String = "{""aps"": {""badge"": ""+1"", ""alert"": ""Estez Mohamad lamaa!"",""sound"": ""default""}}" 
request.Credentials = New NetworkCredential("uorecode", "uorkey") 
request.Method = "POST" 
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData) 
request.ContentType = "application/json" 
request.ContentLength = byteArray.Length 
Dim dataStream As Stream = request.GetRequestStream() 
dataStream.Write(byteArray, 0, byteArray.Length) 
dataStream.Close() 
Dim response As WebResponse = request.GetResponse() 
dataStream = response.GetResponseStream() 
Dim reader As New StreamReader(dataStream) 
Dim responseFromServer As String = reader.ReadToEnd() 
Console.WriteLine(responseFromServer) 
reader.Close() 
dataStream.Close() 
response.Close() 
0

我用Prowl的通知從ASP.NET:

public static void PushNotification(string header, string message) 
{ 
    new Thread(() => 
     { 
      var prowlURL = string.Format("https://api.prowlapp.com/publicapi/add?apikey={YOURKEY}&application={0}&description={1}", header, message); 

      WebClient wc = null; 
      try 
      { 
       wc = new WebClient(); 
       wc.UploadString(new Uri(prowlURL), ""); 
      } 
      catch 
      { 
      } 
      finally 
      { 
       if (wc != null) 
       { 
        wc.Dispose(); 
        wc = null; 
       } 
      } 
     }) { Name = "PushNotification", IsBackground = true }.Start(); 
} 
0

它肯定是結束了。 我用過它,它效果很好。

但是我不確定它的授權是什麼。