问题描述
当我收到推送通知并单击它时,我的应用程序打开并在空白屏幕上停止,只有空白工具栏。
它并不总是发生,仅当应用长时间在后台运行且未被系统杀死时才会发生。 单击正在运行的应用程序并选择我的应用程序仅有助于继续加载
当应用终止运行并从寒冷中打开时,它可以正常工作。当应用程序最近合拢时,它也可以正常工作,并可以通过推送打开
谢谢
Activity attributes:
[MvxActivityPresentation]
[Activity(
AlwaysRetainTaskState = true,Label = "MyPushApp",LaunchMode = LaunchMode.Singletop,Theme = "@style/Theme.MyTheme",Screenorientation = Screenorientation.User)]
public class MainActivity : ExtendedDrawerActivity<MenuVM>,ITabletActivity
Activity OnResume():
protected override void OnResume()
{
base.OnResume();
if (viewmodel.InitializeTask.IsSuccessfullyCompleted && CheckIntentForPushNotification())
{
viewmodel.PushReceived = false;
OpenPushNotification();
}
CheckIntentForPushNotification():
protected bool CheckIntentForPushNotification()
{
return Intent != null && Intent.Extras != null && (Intent.HasExtra(MyFirebaseMessagingService.NotificationBodyTag) || Intent.HasExtra(CheckNotificationsService.localnotificationTag));
}
OpenPushNotification():
private void OpenPushNotification()
{
if (viewmodel.PushReceived || Intent == null)
{
_log.Info("viewmodel.PushReceived || Intent == null");
return;
}
if (Intent.HasExtra(MyFirebaseMessagingService.NotificationBodyTag))
{
string notificationText = Intent.GetStringExtra(MyFirebaseMessagingService.NotificationBodyTag);
string objIds = Intent.GetStringExtra(MyFirebaseMessagingService.ObjectIdTag);
string objType = Intent.GetStringExtra(MyFirebaseMessagingService.ObjectTypeTag);
string objSubtype = Intent.GetStringExtra(MyFirebaseMessagingService.ObjectSubtypeTag);
string moduleType = Intent.GetStringExtra(MyFirebaseMessagingService.ModuleTypeTag);
string notificationType = Intent.GetStringExtra(MyFirebaseMessagingService.NotificationTypeTag);
string folderId = Intent.GetStringExtra(MyFirebaseMessagingService.FolderIdTag);
List<int> ids = objIds?.Split(',')?.Select(id => int.Parse(id))?.ToList();
Mvx.IoCProvider.Resolve<IMvxMessenger>().Publish(new MainPushMessage(this)
{
Text = notificationText,AppLaunchedByNotification = _startWithNotification,NotificationTypeId = string.IsNullOrEmpty(notificationType) ? 0 : Int32.Parse(notificationType),FolderId = string.IsNullOrEmpty(folderId) ? 0 : Int32.Parse(folderId),ObjectIds = ids ?? new List<int>(),ObjectType = objType,ObjectSubtype = objSubtype,});
}
if (Intent.HasExtra(CheckNotificationsService.localnotificationTag))
{
Mvx.IoCProvider.Resolve<IMvxMessenger>().Publish(new MainPushMessage(this)
{
Islocalnotification = true
});
}
Intent = null;
}
Activity OnNewIntent():
protected override void OnNewIntent(Intent intent)
{
base.OnNewIntent(intent);
Intent = intent;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)