react-native android 无法获取注册id

android
标签: #<Tag:0x00007fb84607bb00>

(小猪快跑) #1

android JPushModule.getRegistrationID undefined
但是我android 可以收到通知 但获取不了注册id
ios 可以收到通知也可以获取注册id


#2

1、你所使用的插件的版本号多少?
2、你是在什么时候调的 API ,是否 Android 还没有 init ?


(小猪快跑) #3
componentDidMount() {
        if (Platform.OS === 'android') {
            JPushModule.initPush();
        } else {
            JPushModule.setupPush();
        }
        JPushModule.getRegistrationID((registrationId) => {
             alert(registrationId);
         })
}

最近开始用的jpush 3.0.9

JPushModule.initPush undefined


(Josh Lipan) #4

提供log看下,从进入app初始化开始


(小猪快跑) #5
上午10:39:45 Gradle sync started
上午10:39:54 Gradle sync completed
上午10:39:54 Executing tasks: [:app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources, :jcore-react-native:generateDebugSources, :jcore-react-native:generateDebugAndroidTestSources, :jcore-react-native:mockableAndroidJar, :jcore-react-native:prepareDebugUnitTestDependencies, :jpush-react-native:generateDebugSources, :jpush-react-native:generateDebugAndroidTestSources, :jpush-react-native:mockableAndroidJar, :jpush-react-native:prepareDebugUnitTestDependencies, :react-native-exceptions-manager:generateDebugSources, :react-native-exceptions-manager:generateDebugAndroidTestSources, :react-native-exceptions-manager:mockableAndroidJar, :react-native-exceptions-manager:prepareDebugUnitTestDependencies, :react-native-fetch-blob:generateDebugSources, :react-native-fetch-blob:generateDebugAndroidTestSources, :react-native-fetch-blob:mockableAndroidJar, :react-native-fetch-blob:prepareDebugUnitTestDependencies, :react-native-image-picke... (show balloon)
上午10:40:07 Gradle build finished in 12s 463ms
上午10:40:19 Executing tasks: [:app:assembleDebug]
上午10:40:26 Gradle build finished in 6s 717ms
上午10:41:07 Executing tasks: [:app:clean, :app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources, :app:assembleDebug]
上午10:42:50 Gradle build finished with 24 error(s) in 1m 43s 389ms
上午11:19:01 Executing tasks: [:app:assembleDebug]
上午11:20:59 Gradle build finished with 24 error(s) in 1m 57s 980ms
下午6:11:27 Executing tasks: [:app:assembleDebug]
下午6:14:28 Gradle build finished with 24 error(s) in 3m 0s 207ms
上午9:46:43 Executing tasks: [:app:assembleDebug]
上午9:49:01 Gradle build finished with 24 error(s) in 2m 18s 206ms
上午9:59:43 Executing tasks: [clean, :app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources, :jcore-react-native:generateDebugSources, :jcore-react-native:generateDebugAndroidTestSources, :jcore-react-native:mockableAndroidJar, :jcore-react-native:prepareDebugUnitTestDependencies, :jpush-react-native:generateDebugSources, :jpush-react-native:generateDebugAndroidTestSources, :jpush-react-native:mockableAndroidJar, :jpush-react-native:prepareDebugUnitTestDependencies, :react-native-exceptions-manager:generateDebugSources, :react-native-exceptions-manager:generateDebugAndroidTestSources, :react-native-exceptions-manager:mockableAndroidJar, :react-native-exceptions-manager:prepareDebugUnitTestDependencies, :react-native-fetch-blob:generateDebugSources, :react-native-fetch-blob:generateDebugAndroidTestSources, :react-native-fetch-blob:mockableAndroidJar, :react-native-fetch-blob:prepareDebugUnitTestDependencies, :react-native-imag... (show balloon)
上午10:01:49 Gradle build finished in 2m 5s 374ms
上午10:02:19 Executing tasks: [:app:clean, :app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources, :app:assembleDebug]
上午10:04:35 Gradle build finished with 24 error(s) in 2m 15s 336ms
上午10:10:24 Executing tasks: [:app:assembleDebug]
上午10:10:42 Gradle build finished in 18s 531ms
上午10:14:56 Executing tasks: [:app:assembleDebug]
上午10:15:13 Gradle build finished in 16s 117ms
下午1:34:21 null
          java.lang.NullPointerException
          at com.android.ddmlib.Client.read(Client.java:692)
          at com.android.ddmlib.MonitorThread.processClientActivity(MonitorThread.java:304)
          at com.android.ddmlib.MonitorThread.run(MonitorThread.java:256)
          
下午1:34:21 null
          java.lang.NullPointerException
          at com.android.ddmlib.Client.read(Client.java:692)
          at com.android.ddmlib.MonitorThread.processClientActivity(MonitorThread.java:304)
          at com.android.ddmlib.MonitorThread.run(MonitorThread.java:256)
          
下午2:10:45 Executing tasks: [:app:clean, :app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources, :app:assembleDebug]
下午2:13:14 Gradle build finished with 24 error(s) in 2m 28s 776ms

(Josh Lipan) #6

没看到极光的log,最好用adb抓取android原生日志


(小猪快跑) #7

logcat1.log (1.8 MB)


(Josh Lipan) #8

这个有加吗


(小猪快跑) #9

加了 iOS可以获取 注册ID android 就报错 undefined 但是iOS android 都可以收到通知


(Josh Lipan) #10

你拿官方demo在你测试的android手机跑下试试


(小猪快跑) #11

官方的可以运行 然后怎么改啊


(Josh Lipan) #12

官方的demo你可以获取到RegistrationID吗,按Android手动配置部分检查你的配置是否正确


(小猪快跑) #13

官方可以获取


(小猪快跑) #14

找到原因了,感谢


#15

可否分享下你的出错原因和解决方案