I am trying to create a neat solution for the following requirement:
a) When the user "selects" the notification that my application receives and the application is open and / or in the background, the application will be transferred to the font.
b) When the user βselectsβ the notification and the application closes, a pop-up window appears and the application starts as usual.
I try, but I have success with only one of the above options, not so sad. This is my code:
public void CreateNotification(string title, string desc, string pushUrl, string pushTitle) { var setupSingleton = MvxAndroidSetupSingleton.EnsureSingletonAvailable(ApplicationContext); setupSingleton.EnsureInitialized(); if (!string.IsNullOrWhiteSpace(pushUrl)) { var pushMessageParameterService = Mvx.Resolve<IPushMessageParameterService>(); pushMessageParameterService.SetPushActionParameters(new PushActionParameters { UrlToShow = pushUrl, ViewTitle = pushTitle }); } var intent = new Intent(this, typeof(SplashScreen)); intent.AddFlags(ActivityFlags.NewTask); intent.SetAction(Intent.ActionMain); intent.AddCategory(Intent.CategoryLauncher);
To keep it simple, I have two activities:
public class SplashScreen : MvxSplashScreenActivity
and
public class DashboardView : BaseMvxActivity
If I use "SplashScreen" as a PendingIntent for notification, and the application is already running / open / in the background, it freezes on the splashScreen screen. The MvvmCross log displays "Show ViewModel DashboardViewModel" but stops. OnCreate, Init, and Start are not called. The surge just remains.
If I use "DashboardView" as a PendingIntent for notification, and the application is closed / not active, I just see a white screen at startup and without a pop-up screen.
I would like to have the best of both worlds :). Therefore, when clicking on the push message and the application is open, just bring the application to the forefront (if it is not already). And when the application is closed, show the screen saver, etc. Etc.
I hope I put my question clear.
Thank you very much in advance.