[英]Xamarin iOS Simulator on VS2017 in Windows Showing Black Screen
[英]Need help accessing Apple APN server from a Windows vs2017 program
掙扎了幾天。 我在頭上。 我開發了一個iOS企業應用程序,想要向其中添加推送通知。 我想我可以正確設置客戶端(iPhone),但是我正在開發的Windows應用程序(VB)連接到APNs服務器給我帶來了很多麻煩。
這是我正在互聯網上某個地方找到的非常基本的代碼,其中顯示了異常行:
Using client As New TcpClient()
client.Connect("gateway.sandbox.push.apple.com", 2195)
Using networkStream As NetworkStream = client.GetStream()
txtErrorMessages.AppendText("Client connected." & vbNewLine)
Dim clientCertificate As New X509Certificate(FileSystem.CurrentDirectory & "/apns-dev-key.p12", "abc123")
Dim clientCertificateCollection As New X509CertificateCollection(New X509Certificate(0) {clientCertificate})
' Create an SSL stream that will close the client's stream.
Dim sslStream As New SslStream(client.GetStream(), False, AddressOf ValidateServerCertificate, Nothing)
Try
[exception thrown here] sslStream.AuthenticateAsClient("gateway.sandbox.push.apple.com", clientCertificateCollection, SslProtocols.Default, False)
Catch ex As AuthenticationException
txtErrorMessages.AppendText(String.Format("Exception: {0}", ex.Message) & vbNewLine)
If ex.InnerException IsNot Nothing Then
txtErrorMessages.AppendText(String.Format("Inner exception: {0}", ex.InnerException.Message) & vbNewLine)
End If
txtErrorMessages.AppendText(String.Format("Authentication failed - closing the connection.") & vbnewline)
client.Close()
Return
End Try
End Using
End Using
谷歌搜索帶來了許多不同的變化,但是由於多年來Push Notifications API的變化,它們顯然已經過時了。 我找不到任何有效的方法,但是此摘要至少使我比其他方法更進一步。
例外:
我已經嘗試了Apple開發人員站點上的ID頁生成的.p12文件的多種變體,這些變體是從Mac的鑰匙串中導出的,並遵循了許多教程的步驟,以轉換為其他格式(例如.pem)。或其他內容,但似乎沒有任何效果。
但是,有趣的是,如果我更改了密碼字符串,則異常更改為The specified network password is not correct
,這使我認為它至少可以識別密碼。
誰能帶領我擺脫困境?
謝謝!
我發現我忽略了將證書加載到開發服務器中的操作,在此處進行了介紹: https : //arashnorouzi.wordpress.com/2011/04/13/sending-apple-push-notifications-in-asp-net-% E2%80%93-部分-3- APNS-證書登記上窗口/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.