User specific token for sending Push Notification ? RRS feed

  • Question

  • User355485 posted

    I have a web app and a mobile app-

    1)How to get user specific token when any changes found from web app database?

    2)Where should we write code for getting token for user specific notification ?

    Wednesday, January 10, 2018 9:56 AM

All replies

  • User101185 posted

    you have to override some method according to Xamarin Platform.

    For Xamarin IOS- Add this code in appdelegate public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action < UIBackgroundFetchResult > completionHandler) { Console.WriteLine("PushData received " + userInfo.ToString()); ProcessNotification(userInfo, false); completionHandler(UIBackgroundFetchResult.NewData); }

    For Xamarin Android- Add this code in MainActivity public void OnRegistered(string token, DeviceType deviceType) { //use token here }

    Here is a full code- github.com/xamarinhq/app-evolve

    Wednesday, January 10, 2018 12:58 PM
  • User355485 posted

    how to get static device id for a mobile app so that we can store the device id to database and using this id we can send notification?

    Wednesday, January 10, 2018 6:05 PM
  • User101185 posted

    There are lot's Plugins to get device information.


    Code Example-https://github.com/jamesmontemagno/Xamarin.Plugins/tree/master/DeviceInfo

    you can also use XLab plugins-https://github.com/XLabs/Xamarin-Forms-Labs

    Thursday, January 11, 2018 6:06 AM
  • User355485 posted

    How to use this code for getting firebase token in Xamarin form PCL project?

    Task.Run(() =>
                              var instanceid = FirebaseInstanceId.Instance;
                              var tt = instanceid.GetToken(this.GetString(Resource.String.gcm_defaultSenderId), Firebase.Messaging.FirebaseMessaging.InstanceIdScope);
                              Log.Debug("TAG", "{0} {1}", instanceid.Token, tt);

    Should i use dependency services?

    Thursday, January 11, 2018 7:43 AM