I am testing registering for push notifications on my iOS device using Azure Notifications Hubs.
Following the tutorial here: https://learn.microsoft.com/en-us/azure/notification-hubs/xamarin-notification-hubs-ios-push-notification-apns-get-started
I get a runtime exception when invoking Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => {
Specifically the exception is:
ObjCRuntime.RuntimeException
BlockLiteral.SetupBlock is not supported when the dynamic registrar has been linked away.
Stack trace:
at ObjCRuntime.BlockLiteral.SetupBlock (System.Delegate trampoline, System.Delegate userDelegate, System.Boolean safe) [0x00002] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/ObjCRuntime/Blocks.cs:94
at ObjCRuntime.BlockLiteral.SetupBlock (System.Delegate trampoline, System.Delegate userDelegate) [0x001ef] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/ObjCRuntime/Blocks.cs:205
at WindowsAzure.Messaging.SBNotificationHub.RegisterNativeAsync (Foundation.NSData deviceToken, Foundation.NSSet tags, WindowsAzure.Messaging.ErrorCallback errorCallback) [0x0002d] in <c5112db82ee94ad88e9a597b356dac0c>:0
at MyApp.Test.Azure.AzureNotificationHubService.OnRegisteredForRemoteNotifications (Foundation.NSData deviceToken) [0x00019] in /Users/aventurella/github/my-test-app/MyApp.Test.Azure/Services/AzureNotificationHubService.cs:47
at MyApp.Test.Azure.AppDelegate.RegisteredForRemoteNotifications (UIKit.UIApplication application, Foundation.NSData deviceToken) [0x00001] in /Users/aventurella/github/my-test-app/MyApp.Test.Azure/AppDelegate.cs:47
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/UIKit/UIApplication.cs:63
at MyApp.Test.Azure.Application.Main (System.String[] args) [0x00001] in /Users/aventurella/github/my-test-app/MyApp.Test.Azure/Main.cs:12
So clearly I'm doing something wrong here. Looking for any advice on where I can look to correct it.
The quit/clean up sequence did not work for me. But reading some Microsoft doc, I added
<MtouchExtraArgs>--optimize=-blockliteral-setupblock</MtouchExtraArgs>
to the csproj and that solved the issue for me.
Seems my solution was:
Visual Studio Mac
Visual Studio Mac
Now it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With