question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

iOS app fails when deployed to TestFlight using NotificationHubClient

See original GitHub issue

Description

Maui for iOS works on debug when running visual studio 2022 preview for Mac on macbook and deploying on iPhone device but fails when installed on Iphone using TestFlight. Using NotificationHubClient

nuget package: Microsoft.Azure.NotificationHubs 4.1.0

These are the code snippets;

public async Task<bool> IsDeviceRegisteredForNotificationsAsync()
        {
            var list = await _client.GetRegistrationsByChannelAsync(CleanDeviceToken(), 100);
            var deviceIsRegistered = list.Any();

            return deviceIsRegistered;
        }

        public async Task RegisterForNotifications(IEnumerable<string> tags)
        {
            var trimmedDeviceToken = await SecureStorage.GetAsync(Constants.DeviceTokenKey);

            if (trimmedDeviceToken == null || trimmedDeviceToken.Length == 0)
                return;

            var deviceRegisters = await _client.GetRegistrationsByChannelAsync(trimmedDeviceToken, 100);

            if (!deviceRegisters.Any())
            {
                await _client.CreateAppleNativeRegistrationAsync(trimmedDeviceToken, tags);
                await _client.CreateAppleTemplateRegistrationAsync(trimmedDeviceToken, Constants.APNTemplateBody, tags);
            }
        }

Steps to Reproduce

  1. Checked in working code to Azure Devops repository.
  2. Merged code to master branch
  3. CI pipelines kicks off
  4. IPA file is generated
  5. Run Release to deploy signed ipa file
  6. App is deployed to TestFlight
  7. Install the app to my iPhone.
  8. Open the app
  9. Successfully logged in
  10. Throws an error when it get to NotificationHubClient lines. Please see logs

System.Runtime.Serialization.XmlObjectSerializerReadContext.ThrowRequiredMemberMissingException(XmlReaderDelegator xmlReader, Int32 memberIndex, Int32 requiredIndex, XmlDictionaryString[] memberNames) System.Runtime.Serialization.SerializationException: ErrorInLine, 1, 1162 UnexpectedElementExpectingElements, Element, DeviceToken, http://schemas.microsoft.com/netservices/2010/10/servicebus/connect, PushVariables

Link to public reproduction project repository

N/A

Version with bug

6.0.424

Last version that worked well

6.0.424

Affected platforms

iOS

Affected platform versions

ios 15.7, ios 16

Did you find any workaround?

No

Relevant log output

* System.Runtime.Serialization.XmlObjectSerializerReadContext.ThrowRequiredMemberMissingException(XmlReaderDelegator xmlReader, Int32 memberIndex, Int32 requiredIndex, XmlDictionaryString[] memberNames)

System.Runtime.Serialization.XmlObjectSerializerReadContext.GetMemberIndexWithRequiredMembers(XmlReaderDelegator xmlReader, XmlDictionaryString[] memberNames, XmlDictionaryString[] memberNamespaces, Int32 memberIndex, Int32 requiredIndex, ExtensionDataObject extensionData)

System.Runtime.Serialization.ReflectionXmlReader.ReflectionReadMembers(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] , ClassDataContract , Object& )

System.Runtime.Serialization.ReflectionReader.ReflectionReadClass(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] , ClassDataContract )

System.Runtime.Serialization.ReflectionXmlClassReader.ReflectionReadClass(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )

System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator , XmlObjectSerializerReadContext )

System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract , XmlReaderDelegator )

System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract& dataContract)

System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)

System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator , Boolean , DataContractResolver )

System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator , Boolean , DataContractResolver )

System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator , Boolean )

System.Runtime.Serialization.DataContractSerializer.ReadObject(XmlReader )

Microsoft.Azure.NotificationHubs.Messaging.EntityDescriptionSerializer.Deserialize(XmlReader reader, String typeName)

Microsoft.Azure.NotificationHubs.NotificationHubClient.<ReadEntityAsync>d__205`1[[Microsoft.Azure.NotificationHubs.AppleRegistrationDescription, Microsoft.Azure.NotificationHubs, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].MoveNext()

Microsoft.Azure.NotificationHubs.NotificationHubClient.<>c__DisplayClass195_0`1.<<CreateOrUpdateRegistrationImplAsync>b__0>d[[Microsoft.Azure.NotificationHubs.AppleRegistrationDescription, Microsoft.Azure.NotificationHubs, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].MoveNext()

Microsoft.Azure.NotificationHubs.NotificationHubRetryPolicy.<RunOperation>d__4`1[[Microsoft.Azure.NotificationHubs.AppleRegistrationDescription, Microsoft.Azure.NotificationHubs, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].MoveNext()

Microsoft.Azure.NotificationHubs.NotificationHubRetryPolicy.<RunOperation>d__4`1[[Microsoft.Azure.NotificationHubs.AppleRegistrationDescription, Microsoft.Azure.NotificationHubs, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].MoveNext()

Microsoft.Azure.NotificationHubs.NotificationHubClient.<CreateOrUpdateRegistrationImplAsync>d__195`1[[Microsoft.Azure.NotificationHubs.AppleRegistrationDescription, Microsoft.Azure.NotificationHubs, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].MoveNext()

App.Client.Core.Infrastructure.Notifications.NotificationManager.RegisterForNotifications(IEnumerable`1 tags)

App.Client.Maui.ViewModels.LoginPageViewModel.RequestLogin()

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ikeoriaku123commented, Nov 8, 2022

Feel free to use either approach. The --linkskip option may make your app a bit bigger (it’s probably negligable, but if you care about app size you might want to test and see the difference in your case), while enabling the interpreter might make your app slightly slower (which is usually not a problem unless you’re a game chasing FPS). I’d say that stick with what you’ve found to work.

Thanks to @rolfbjarne and @jfversluis. I really appreciate your help.

0reactions
ikeoriaku123commented, Nov 14, 2022

OK, so I think this is handled for now, I’m also reaching out to the team behind this library to see if we can make this better without extra settings. Happy push notificationing!

Thanks @jfversluis

Read more comments on GitHub >

github_iconTop Results From Across the Web

ios - Some registrations don't seem to be registered in ...
Once we switched the Notification Hub to the production APNS endpoint, all the TestFlight users were able to receive notifications because ...
Read more >
Push notifications not reaching my device
To test that my Azure notification hub was working I sent a test message from www.pushtry.com and that said the message was sent...
Read more >
[Resolve]-Azure Notifications hub .net api not working async
I have followed this tutorial to create a push notification hub for an IOS app. When i run the code private static async...
Read more >
Azure Hub Notifications aren't received on iPhones
The notifications are received on iPhones when debugging in Debug mode, when the packages are created in Release mode, we see the notifications ......
Read more >
Azure Notification Hub Application mode using production ...
When I am debugging locally, i am using a development provision profile, and I never managed to receive any notification. As for today,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found