I am having two major issues trying to use the Urban airship with Xamarin. My app is a Xamarin forms app, but I am only working with iOS at the moment.

#1 my app has a login screen and needs to associate an existing user in an existing system with Urban airship. At login time I set the named user using the API, but the named user never seems to be associated with the device. I have two devices I am testing on. One is working the other will not associate to the user. I switched users on that device and the new user became associated. I then switched back to my original test user and I still received notifications for the previous user for a short time and then never received notifications for the currently logged in user (it has been more than 8 hours since I set the user and I still don't get notifications). notifications sent to an audience of all work on both devices. I followed the advice of another forum post as well and set the UserPushNotificationEnabledbyDefault = false at start up and enabled notifications when the user logs in. I also tried calling UpdateRegistration(). This is a critical piece of my app that must work

#2 I implemented a PushDelegate so that I could capture notifications while the app is running and in the background, but I have not been able to have this work reliably. when I debug the only time the debugger seems to hit my delegate's methods is if I call the base method (which then throws an error). I'm not sure if this is actually a problem with the methods being called or if it is a problem with debugging (I am coding in visual studio btw). If I implement the default methods in the app delegate for handling notifications they work every time.

Any assistance would be greatly appreciated.

Didn't find what you were looking for?

New post

Comments

7 comments

  • Could you share your app delegate and your Xamarin Forms .cs file?

    Comment actions Permalink
    0
  • Is there a way I can provide the code to you privately?

    Comment actions Permalink
    0
  • Thank you for sending that data.

    #1) In your AppDelegate.cs file, try removing the following lines:

    • UAirship.Push.UserPushNotificationsEnabledByDefault = false;
    • UAirship.Push.BackgroundPushNotificationsEnabledByDefault = false;

    Those registration calls might be running into a race condition with the following lines that causes Named Users to not be set properly in-time:

              UAirship.Push.UserPushNotificationsEnabled = true;
              UAirship.Push.BackgroundPushNotificationsEnabled = true;

     

    #2) What is the error that you are receiving? 

    • Can you take a look through our Xamarin Resources and compare your app to our iOS sample app? Doing so may be able to shed some light as to what is going wrong with your PushDelgate
    • It could be that the completion handler is not being called and that might be why it's crashing. If this is the case, I would try adding that in.
    Comment actions Permalink
    0
  • #1) I added this code after following a suggestion on this forum because on how to handle problems with named users not being assigned after a logon. Taking it out doesn't change anything.

     

    #2) The app is not crashing. The PushDelegate is just not getting called when a message is recieved. The notifications are sending and if I override the notification handling methods in the AppDelegate they do get called, but If I call the base method in the PushDelegate methods then those methods throw an exception saying that I should not call the base methods.

    No mater what code I put in the push delegate it never runs (even throwing an exception) unless it is calling the base method.

    I will give the ios samples a look

    Comment actions Permalink
    0
  • I figured out the problem with the Delegate. My app wasn't holding onto a reference to the PushDelegate and I guess the UA library only has a weak reference so it was being garbage collected.

    I'm still having issues with devices being associated with the named user. It seems like only 1 of my devices can be associated at a time. as soon as one is the other stops working.

    Comment actions Permalink
    0
  • There is a limit of 20 devices per Named User.  Could this be the issue?

    I have your app key from the files you sent earlier.  What are you using for the named user? Also, can you provide the device ids in question?  Here is a document to help: How to Find your Device Identifier

    Comment actions Permalink
    0
  • Named users are registering now. I'm not sure what is different.

    I have the app installed on about 4 or 5 devices all logged in an the same user. Some of these devices have had the app uninstalled and reinstalled and the device reset multiple times. Its also possible that some emulators registered as this named user, but I seemed to still have the problem when I switched to a different user.

    my named user identifier is a number there are two in the system right now. (45884,7777)


    Is there a way to clear devices? Do unused devices fall off the list after some time?

    Comment actions Permalink
    0

Please sign in to leave a comment.