[Xamarin]為什麼透過 Azure Notification Hubs 推播通知,App會收不到?

環境: iOS,Xamarin

最近透過 Azure Notification Hubs 來推播通知, Android 都可以正常收到,但 iOS 就是收不到

都依照「適用於 Xamarin 應用程式的 iOS 推播通知和通知中樞」這樣來做,

透過 Azure Notification Hubs 的 Test Send 來測試, 就是收不到。

只是在測試的過程中,第一次測試在結果那會有資料,第二次測試,結果的欄位就是空的。

這樣比較看不出實際的狀況,使用 VS.NET 的 Server Explorer 來看 Notification Hubs 的狀況比較清楚。

一開始將 App Run 起來後,可以看一下 Device Registrations 這個 Tab 裡面的註冊是否有資料。

如果有資料的話,表示 App 已正常跟 Azure Notification Hubs 註冊好了,如下,

再來切到 Test Send 這個 Tab ,然後 Type 選擇 Apple ,然後再按下 Send Button 來測試推播通知,如下,

但是 App 沒有收到任何的通知。

再切到 Device Registrations 這個 Tab,按下 Refresh 的 Button,結果原本的註冊資訊不見了 .....

後來參考「Azure Notification Hub registrations disappear when sending a notification」這篇,

因為我上傳給 Azure Notification Hub 時是使用 development 的 p12,並選擇 sandbox。

所以專案的 iOS Bundle Signing 也要使用 Developer 的哦,如下,

鳴... 搞了好久,原來是這樣子的問題 .... 

參考資料

適用於 Xamarin 應用程式的 iOS 推播通知和通知中樞

Azure Notification Hub registrations disappear when sending a notification

How to view device registrations for notification hubs

Hi, 

亂馬客Blog已移到了 「亂馬客​ : Re:從零開始的軟體開發生活

請大家繼續支持 ^_^