为什么待定意图失去了我的额外功能(Firebase通知)?

时间:2018-11-14 12:54:00

标签: android xamarin android-notifications android-pendingintent

在我向您展示代码片段之前,我想说的是当应用程序处于前台时它正在工作。当收到通知时,我试图立即启动活动,它运行良好,但是待处理的意图会失去额外的意图,并且我无法在“加载活动”中获取数据。为清楚起见,应用程序运行时不会显示通知,因此,每当用户单击通知应用程序时,应用程序就会在后台。

通知接收者:

    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);
        TransferInstances.Instance.ScreenHeight = this.Resources.DisplayMetrics.HeightPixels;
        TransferInstances.Instance.ScreenWidth = this.Resources.DisplayMetrics.WidthPixels;
        if (FirstLaunch)
        {
            try
            {
                AppCore.RegisterServices(GetLocalFilePath("x.db3"), new AlertDialogService(), null, new DeviceIdService());
                CachedImageRenderer.Init(true);
                CarouselView.FormsPlugin.Android.CarouselViewRenderer.Init();
                FFImageLoading.ImageService.Instance.Initialize();
                Forms.Init(this, savedInstanceState);
                GetStartedBtn.Click += GetStartedBtn_Click;
                FBase.Instance.InitFirebase(this);
                FBase.Instance.InitGoogleSignIn(this);
                CreateNotificationChannel();
                FirstLaunch = false;
            }catch(Exception){}
        }
        Intent m_intent = new Intent(this, typeof(MainActivity));
        bool notificationReceived = false;
        if (int.TryParse(Intent.GetStringExtra("CookingAdviceId"), out int CookingAdviceId))
        {
            notificationReceived = true;
            m_intent.PutExtra("CookingAdviceId", CookingAdviceId);
        }
        else if (int.TryParse(Intent.GetStringExtra("NewsId"), out int NewsId))
        {
            notificationReceived = true;
            m_intent.PutExtra("NewsId", NewsId);
        }
        else if (int.TryParse(Intent.GetStringExtra("SaleId"), out int SaleId))
        {
            notificationReceived = true;
            m_intent.PutExtra("SaleId", SaleId);
        }
        else if (int.TryParse(Intent.GetStringExtra("RecipeId"), out int RecipeId))
        {
            notificationReceived = true;
            m_intent.PutExtra("RecipeId", RecipeId);
        }
        else if (int.TryParse(Intent.GetStringExtra("SpecialProductid"), out int SpecialProductid))
        {
            notificationReceived = true;
            m_intent.PutExtra("SpecialProductid", SpecialProductid);
        }
        if (notificationReceived)
        {
            m_intent.AddFlags(ActivityFlags.NoAnimation);
            m_intent.AddFlags(ActivityFlags.ClearTop);
            StartActivity(m_intent);
        }
    }

这是我尝试访问更多意图时的加载活动OnCreate

>>> df1.shape
(1812871, 7)
>>> df1.dtypes
CHROM     object
POS        int32
ID        object
REF       object
ALT       object
QUAL        int8
FILTER    object
dtype: object
>>> df1.head()
  CHROM    POS           ID REF   ALT  QUAL  FILTER
0    20  60343  rs527639301   G   [A]   100  [PASS]
1    20  60419  rs538242240   A   [G]   100  [PASS]
2    20  60479  rs149529999   C   [T]   100  [PASS]
3    20  60522  rs150241001   T  [TC]   100  [PASS]
4    20  60568  rs533509214   A   [C]   100  [PASS]
>>> df2 = df1.head(30)
>>> df3 = df1.head(3000)

0 个答案:

没有答案