0

My app uses MvvmCross and I have a strange issue. Sometimes when I navigate after a notification was clicked the values that arrive in the IMvxBundle in the InitFromBundle method are wrong.

Here is the intent creation in the push notification service:

MvxViewModelRequest request = new MvxViewModelRequest ();
request.ViewModelType = typeof(RecomendationPageViewModel);
request.ParameterValues = new Dictionary<string,string> ();
request.ParameterValues.Add ("ID", intent.Extras.Get ("ID").ToString ());
newIntent = Mvx.Resolve<IMvxAndroidViewModelRequestTranslator> ().GetIntentFor (request);

Here is the InitFromBundle method in the RecomendationPageViewModel:

 protected override void InitFromBundle (IMvxBundle parameters)
    {
        base.InitFromBundle (parameters);
        if (parameters.Data.ContainsKey ("ID"))
        {
           long id = long.Parse (parameters.Data ["ID"]);
           Recomendation rec = CommunicationManager.Recomendations.GetRecomendation(AppConfiguration.Instance.User.ID, id);
           SharedContext.CurrentViewedRecomendation = rec;
           Recomendation = new RecomendationViewModel (rec, null);        
        }
}

Sometimes its ok but sometimes I get the value of an old bundle. for example If while working with the app I navigated to this ViewModel with an ID of X and then got the notification I will get that same ID X and not the new one, even If I have navigated away from that ViewModel before the notification have arrived.

UPDATE

I have narrowed it down. If I received a push notification with an ID X, pressed on it and then received a new notification with an ID of Y i will still get to the ViewModel with an ID of X... Do I need to clear something once a notification is clicked?

Do I need to reset the bundle once I am done with it? am I doing something wrong?

Thanks

Amit

Amit Raz
  • 5,013
  • 8
  • 33
  • 55
  • Search for general Android solutions - look at questions like http://stackoverflow.com/questions/7370324/notification-passes-old-intent-extras - and plenty of others out there – Stuart Jun 26 '14 at 15:07
  • @Stuart Thanks!! I search for hours... guess I did not use the right terms – Amit Raz Jun 27 '14 at 08:31

0 Answers0