реагировать на собственное push-уведомление: RNPushNotification: java.lang.NullPointerException - PullRequest
0 голосов
/ 26 ноября 2018

Я использую метод localNotification реагировать-родной-push-уведомления.но ничего не происходит как в Android и IOS.я связываю библиотеку.в выводе android logcat я вижу вывод ниже:

11-25 18:46:38.373 618 735 E RNPushNotification: failed to send push notification
11-25 18:46:38.373 618 735 E RNPushNotification: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.ComponentName android.content.Intent.getComponent()' on a null object reference
11-25 18:46:38.373 618 735 E RNPushNotification: at com.dieam.reactnativepushnotification.modules.RNPushNotificationHelper.getMainActivityClass(RNPushNotificationHelper.java:56)
11-25 18:46:38.373 618 735 E RNPushNotification: at com.dieam.reactnativepushnotification.modules.RNPushNotificationHelper.sendToNotificationCentre(RNPushNotificationHelper.java:137)
11-25 18:46:38.373 618 735 E RNPushNotification: at com.dieam.reactnativepushnotification.modules.RNPushNotification.presentLocalNotification(RNPushNotification.java:156)

и настройка gradle проекта:

buildToolsVersion = "27.0.3"
minSdkVersion = 19
compileSdkVersion = 27
targetSdkVersion = 27
supportLibVersion = "27.1.1"

это мой код.я использую метод настройки в App.js, прежде чем реагировать на компонент приложения.

export const configure = ()=>{

  PushNotification.configure({

    onRegister: function(token) {
      console.log( 'TOKEN:', token );
    },
    onNotification: function(notification) {
      console.log( 'NOTIFICATION');
    },

    permissions: {
      alert: true,
      badge: true,
      sound: true
    },

    popInitialNotification: true,
    requestPermissions: true,
  });


}


export const localNotification = (title="",bigText="" )=>{

  PushNotification.localNotification({

    title:title,
    message: bigText,
    playSound: true,
    soundName: 'default',


  });

}

это мой AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.mahan">

 .....
  .....


  <uses-permission android:name="android.permission.GET_TASKS" />                       <!-- <- Add this line -->
  <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>           <!-- <- Add this line -->
  <uses-permission android:name="android.permission.VIBRATE"/>

  <application
    android:name=".MainApplication"
    android:label="@string/app_name"
    android:icon="@mipmap/ic_launcher"
    android:allowBackup="false"
    android:theme="@style/AppTheme">

    <meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_name"
                android:value="xchannel"/>
    <meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_description"
                android:value="YOUR NOTIFICATION CHANNEL DESCRIPTION"/>
    <!-- Change the resource name to your App's accent color - or any other color you want -->
    <meta-data  android:name="com.dieam.reactnativepushnotification.notification_color"
                android:resource="@android:color/white"/>


    <activity
      android:name=".MainActivity"
      android:label="@string/app_name"
      android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
      android:windowSoftInputMode="adjustResize">


      <intent-filter>
        <action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />

        <!-- enable deep linking -->
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

        <!-- for example pay://herfehplus !-->
        <data android:scheme="pay"
              android:host="payhost"
        />


      </intent-filter>
    </activity>


    <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
  </application>

</manifest>
...