2

我試圖在我的Xamarin.Forms應用程序中實現推送通知。
我已經按照this Microsoft doc,但我對Xamarin.Forms Azure推送通知 - 「MobileServiceInvalidOperationException:您無權查看此目錄或頁面」

await push.RegisterAsync(RegistrationID, templates); 

線得到一個Unauthorized錯誤。例外情況如下:
Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException: You do not have permission to view this directory or page.

我已經加入了Sender ID(從火力地堡)(他們稱之爲「項目編號」中的文檔)

public class PushHandlerBroadcastReceiver : GcmBroadcastReceiverBase<GcmService> 
{ 
    public static string[] SENDER_IDS = new string[] { "<my_sender_id_here>" }; 
} 

我還添加了Server key(從火力地堡)添加到Azure門戶的通知中心的「Google(GCM)API密鑰」中。

我已登錄到我的AVD上的Google帳戶。 (我也使用Azure AD B2C登錄Azure MobileServicesClient,但我認爲這不重要。)

我找到了other people with this same issue(搜索「許可」,直接鏈接不起作用),但它只有一個實例。沒有人提供解決方案。

我缺少什麼?

回答

4

我想你只是沒有看到我的任何答覆,因爲我已經回答了這六次。

目前應用服務推送存在問題。修復需要在Azure應用服務中推出,所以它不會很快。

相反,請參閱我的書第5章http://aka.ms/zumobook - 它提供了您需要的確切替代代碼。所提供的代碼將在修復和現在一起工作,所以它不像你的代碼將不得不再次改變。

+0

不能說我遇到過任何經典的Google。謝謝!我會嘗試一下! – Marcus

+1

這對我有效,我使用了替代代碼('client.InvokeApiAsync (...)'方法,而不是'push.RegisterAsync(...))。謝謝阿德里安! – Marcus

0

我想我找到了一個更合理的解決方案。由於我們都遵循移動應用程序教程,因此我們在後端添加了身份驗證。當使用我們的設備註冊推送通知時,我們並未首先進行身份驗證,因此我們所有的設備註冊都失敗(並且沒有顯示在我們的中心的「設備註冊」選項卡中(在Visual Studio中)。更改選項「採取的操作當請求未通過身份驗證'爲'允許匿名請求(無操作)'做的伎倆!設備顯示並推送通知發送!

相關問題