Get WNS Notifications on Windows silver silverlight 8.1

I have an application for Windows phone 8.1 silverlight where I want to receive Notfications using the new WNS framework.

I have package.appxmanifest: <identity name="4657xxxxxxx" publisher="CN=xxxxx" version="1.0.0.0"/> and added it to the mobile services hub.

To do this, I removed the old links for using MPNS and added the following for WNS:

using Windows.UI.Notifications;

using Windows.Networking.PushNotifications;

using Windows.UI.StartScreen;

This led to a new way to get the URI channel:

  public static PushNotificationChannel CurrentChannel { get; private set; } public async static Task<bool> UploadChannel() { bool newChannel = false; var channel = await Windows.Networking.PushNotifications.PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync(); var settings = Windows.Storage.ApplicationData.Current.LocalSettings.Values; object oldChannel; settings.TryGetValue("channelURI", out oldChannel); if ((oldChannel as PushNotificationChannel).Uri != CurrentChannel.Uri) { settings.Add("channelURI", CurrentChannel); newChannel = true; } try { await App.MobileService.GetPush().RegisterNativeAsync(channel.Uri); } catch (Exception exception) { CurrentChannel.Close(); HandleRegisterException(exception); } CurrentChannel.PushNotificationReceived += CurrentChannel_PushNotificationReceived; return newChannel; } private static void HandleRegisterException(Exception exception) { MessageBox.Show("error - retry pushchannel"); } 

In addition, I deleted ID_CAP_PushNotification based on Microsoftsoft update information. I do not receive the channel, I receive an error message:

The app does not have cloud notification capabilities. (Exception from HRESULT: 0x803E0110)

Solution I searched for an error and found this link . This can be resolved as indicated in the answer below by contacting package.appxmanifest and turning on the Internet (Client and Server)).

ERROR 2 Then the UploadChannel() function should work. However, the register API call await App.MobileService.GetPush().RegisterNativeAsync(channel.Uri); leads to an error on the server:

Message = 'Failed to register on mpns platform. Received error: "Unsupported uri channel: https : //db3.notify.windows.com .,.

The error makes sense, but I have no idea how to solve it.

Ekstra On the server, I can subscribe with a URI and receive notifications. But not on the client. Is this how it should be or?

+6
source share
4 answers

On the client side:

Ideally, to use WNS, you should remove all MPNS links from WMAppManifest.xml and add the information provided by the Windows Store to your package.manager package.

I understand that you are switching from WP8 to WP8.1. So, in your package.appxmanifest, edit the code so that it looks like this:

 <Identity Name="4657xxxxxxx" Publisher="CN=xxxxx" Version="1.0.0.0" /> <mp:PhoneIdentity PhoneProductId="xxxx" PhonePublisherId="00000000-0000-0000-0000-000000000000" /> 

Note: 0s in PhonePublisherId are intentional. I have no idea why, but the application will not work if I have not provided them as such.

You correctly execute the uri request for the channel:

 PushNotificationChannel channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync(); string channelUri = channel.Uri; 

You must also select the Internet (client and server) check box in Package.appxmanifest for verification.

To receive notifications on the client, you must intercept the received notification, as described here: https://msdn.microsoft.com/en-us/library/windows/apps/xaml/jj709907.aspx

On the server side:

The "Unsupported Channel URI" error occurs because you are using MPNS methods to process URIs on an Azure server.

Contact here for the correct way using WNS: http://azure.microsoft.com/en-us/documentation/articles/mobile-services-dotnet-backend-windows-universal-dotnet-get-started-push/

+2
source

Adding the InternetClient feature should fix this error.

Creating a notification channel results in an error WPN_E_CLOUD_INCAPABLE Cause. The application did not announce the possibility of the Internet in the application manifest (package.appxmanifest). Correct: Make sure the application manifest announces Internet features. In the Visual Studio manifest editor, this option can be found on the Features tab in the form of "Internet (client)".

+2
source

The .NET client SDK for Azure Mobile does not currently support the use of WNS in Silverlight Windows Phone 8.1 applications. You must use MPN or change the project to a NON-silverlight project project.

Link (see Elio answer): https://social.msdn.microsoft.com/Forums/azure/en-US/1aa29977-a26d-4054-89b2-c853cbd35c18/wns-for-windows-phone-silverlight-81- apps-with-azure-mobile-services? forum = azuremobile

I'm not sure that they will update it to support this, since Silveright for 8.1 is primarily designed for backward compatibility with existing applications, and not many of them use mobile services because they are newer.

0
source

In my case, select the ARM platform in my project settings, did the trick. I was in "any processor."

0
source

Source: https://habr.com/ru/post/987348/


All Articles