Since the public release of iOS 13 push notifications appear to no longer work for my Xamarin.Forms iOS project. I currently use Azure Notification Hub to send test notifications and previously, my iPhones would get notifications with no problem. Since iOS13 this is no longer happening.
I don't use OneSignal but they did post an article about the changes that were made for Push Notifications: https://onesignal.com/blog/ios-13-introduces-4-breaking-changes-to-notifications/
Is this problem still present? Or has anyone got any sources to confirm this issue other than SignalOne?
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken) {
if (Hub == null) {
Hub = new SBNotificationHub(ApiConstants.ListenConnectionString, ApiConstants.NotificationHubName);
}
// Following from the comments with FreakyAli, I have added these 3 lines
Byte[] result = new byte[deviceToken.Length];
Marshal.Copy(deviceToken.Bytes, result, 0, (Int32)deviceToken.Length);
String token = BitConverter.ToString(result).Replace("-", "");
// Update registration with Azure Notification Hub
Hub.UnregisterAllAsync(token, (error) => {
if (error != null) {
Debug.WriteLine($"Unable to call unregister {error}");
}
NSSet tags = null;
Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => {
if (errorCallback != null) {
Debug.WriteLine($"RegisterNativeAsync error: {errorCallback}");
}
});
});
}
The code above worked all the time but during debugging I have noticed it no longer steps into Hub.UnregisterAllAsync()
and I believe it is causing some error? (Can't make any sense of it though)
=================================================================
Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x1bffaaf44):
0x1bffaaf34 c0 03
5f d6 1f
20 03 d5
1f 20
03 d5 01 ec
7c 92
.._..
...
..
..|
.
0x1bffaaf44 20 00 c0 3d c3 f9 ff 10
62 04 c1 3c 02 0c 40 92
..=.
..
.b.
.<.
.@.
0x1bffaaf54
63 00 02
cb 61 00
c0 3d 00 1c a1 4e
05 00
00
14
c.
..
a.
.=.
.
.
N....
0x1bffaaf64 1f 20 03 d5
1f 20 03 d5 1f 20 03 d5 20 0c
c1 3c . ..
. ... .. ..<
I have found these though - but I'm unsure how related these are to my current problem. https://github.com/Azure/azure-notificationhubs-dotnet/issues/88 https://github.com/Azure/azure-notificationhubs-dotnet/issues/96
deviceToken
is populated and it does not even step into the method to check whether or noterror
was populated. – MattVon Oct 7 '19 at 13:10Xamarin.Azure.NotificationHubs.iOS-updated
(v. 1.2.5.3) which has not been updated for over a year ago (nuget.org/packages/Xamarin.Azure.NotificationHubs.iOS-updated) Now I am referencingXamarin.Azure.NotificationHubs.iOS
(v 2.0.4 - nuget.org/packages/Xamarin.Azure.NotificationHubs.iOS/2.0.4) and despite my minor error, I can actually register and receive notifications again. I can only assume currently, this is the root source of my problem. – MattVon Oct 7 '19 at 14:36on iOS there are some changes to the async method signatures for methods such as UnregisterAllAsync, RegisterNativeAsync, and RegisterTemplateAsync. These methods used to have a second parameter that took a callback. They no longer do... It is easier to use the non-async versions of these methods than to rewrite to be properly Async/Await. The non-async versions have the same signature so the only code change would be to remove the Async suffix from the method calls.
– Phil Seeman Dec 9 '19 at 4:03