-
Notifications
You must be signed in to change notification settings - Fork 130
Open
Description
Can some one help I have the same problem IOS14, and when i try the test in Azure Portal I get
apple | 6321218213637372908-5225854469778412245-3 | The Push Notification System handle for the registration is invalid
with this basic payload {"aps":{"alert":"Notification Hub test notification"}}, and the registration is removed from the hub
Is in Xamarin forms and the code for registration in AppDelegate are:
Hub.UnregisterAll(deviceToken, (unregisterError) =>
{
if (unregisterError != null)
{
Console.WriteLine("Error calling Unregister: {0}", unregisterError.ToString());
return;
}
NSSet tags = new NSSet("xxxxxx"); // create tags if you want
var expirationTime = DateTime.UtcNow.AddYears(1); // Set expiration time to one year from now
var template = new Dictionary<string, string>
{
{ "body", "{\"aps\":{\"alert\":\"$(message)\"}}" }
};
Hub.RegisterNative(deviceToken, tags, (errorCallback) =>
{
if (errorCallback != null)
{
Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString());
return;
}
});
Hub.RegisterTemplate(deviceToken, "defaultTemplate", template["body"], "defaultTemplate", tags, (registerError) =>
{
if (registerError != null)
{
Console.WriteLine("RegisterTemplateAsync error: " + registerError.ToString());
return;
}
var tokenStringBase64 = deviceToken.Description;
byte[] bytes = deviceToken.ToArray<byte>();
string[] hexArray = bytes.Select(b => b.ToString("x2")).ToArray();
var DeviceToken = string.Join(string.Empty, hexArray);
App.Current.Properties["idregistration"] = Hub.Handle.ToString();
App.Current.Properties["tokenNoti"] = DeviceToken.ToString();
App.Current.SavePropertiesAsync().GetAwaiter();
});
});
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels