Search code examples
push-notificationxamarin.formsazure-notificationhubwnswin-phone-silverlight-8.1

WinPhone 8.1 register Push Id to Azure notification hub error: The type name 'MobileService' does not exist in the type 'App'


I would like to configure Push notifications for a Xamarin Forms Windows 8.1 Silverlight project. Originally I was using MPNS but am attempting to switch over to WNS. Switching over I am now running into an error when I am attempting to call the method to register my device to Azures notification hub.

The line im calling that throws the error is:

await App.MobileService.GetPush().RegisterAsync(channel.Uri);

and the error thrown is:

The type name 'MobileService' does not exist in the type 'App'

I have the NuGet package Microsoft.WindowsAzure.MobileServices installed but apparently this doesn't contain the definition.

I am following the following guide to setup my push notifications (Under the section "Add push notifications to your app"):

https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-windows-store-dotnet-get-started-push/

I've also looked up how to do this on other sites and I don't see much difference to the instructions, nor do I see what I might be missing...

Anyhow if anyone has any ideas what package or reference I might be missing (or what else might be wrong with that call) I'd appreciate the help! Thanks!


Solution

  • In case anyone runs into this issue I solved this problem adding:

    public static MobileServiceClient MobileService = new MobileServiceClient(Utilities.Constants.ApplicationURL, Utilities.Constants.ApplicationKey);
    

    and updating my call like so:

    await MobileService.GetPush().RegisterNativeAsync(channelUri);
    

    Hope this helps!