点击通知后没有更新应用

时间:2018-06-27 06:54:48

标签: android react-native notifications

我使用react native并编写本地模块进行通知!所以我想当我点击通知时只是恢复应用程序而没有重新启动 我在下面的代码中编写了代码,但是这项工作是在该应用首次运行时执行的,然后在每次单击通知后重新启动该应用。怎么了?

      Class cl = null;
      try {
          cl = Class.forName(packageName + ".MainActivity");
      } catch (ClassNotFoundException e) {
          //TODO: if you want feedback
      }
      Intent openIntent = new Intent(reactContext, cl);
      openIntent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
      PendingIntent contentIntent = PendingIntent.getActivity(reactContext, 0, openIntent, 0);

      Notification.Builder notificationBuilder = new Notification.Builder(reactContext)
        .setSmallIcon(smallIconResId)
        .setVibrate(new long[]{0,500})
        .setContentTitle("test")
        .setOngoing(true)
        .setContentText("test is here :)")
        .setContentIntent(contentIntent);

1 个答案:

答案 0 :(得分:0)

好的,我找到了答案,我更改了清单,现在一切正常。

  <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:windowSoftInputMode="adjustResize"
    android:launchMode="singleTask"  // <-- add this line
  >