Closed favalosdev closed 3 weeks ago
The issue you're describing is related to the Pushwoosh SDK not being properly linked to the React Native Android project. Given the error description, the problem seems to be that the native Pushwoosh module isn't being recognized in the React Native environment.
May I ask you to check the following:
pushwoosh-react-native-plugin
has been added to android/settings.gradle
and android/app/build.gradle
. If the linking was failed, please rebuild the Android project.
import Pushwoosh from 'pushwoosh-react-native-plugin';
Pushwoosh.init({ "pw_appid" : "YOUR_PUSHWOOSH_APP_ID" , "project_number" : "YOUR_FCM_SENDER_ID" });
4. It might be possible that there's a compatibility issue with the versions of React Native and Pushwoosh SDK.
Ensure you're using the [latest version](https://github.com/Pushwoosh/pushwoosh-react-native-plugin/releases) of the Pushwoosh plugin and see if the issue persists. The latest version is 6.1.32
If you're still facing the issue, upload the full stack trace of the error.
@favalosdev Can you please provide a detailed, step-by-step description of how you are running the application? This will help us better understand the context and troubleshoot the issue. Thank you!
@favalosdev, we partially reproduced this issue, but it depends on the certain behavior. May I ask you to clarify us how do you build and launches the android project?
For example, in Expo, if you run the project with the npx expo start
command, you may get an error, but if you launch the project with the npx expo run:ios/android
command, then there is no error.
Could you please provide us a reproducer app? (you also may send us a link to help@pushwoosh.com for privacy reasons)
Hello, @favalosdev
For an Expo app prebuild is required. Prebuild entails the generation of native runtime code for the project, resulting in the construction of the 'ios' and 'android' directories. Through prebuilding, the native modules that utilize CocoaPods, autolinking, and other configuration plugins are automatically linked and configured.
After running:
npx expo prebuild
You can build and run native projects:
# Build and run your native iOS project
npx expo run:ios
# Build and run your native Android project
npx expo run:android
Otherwise you may face the TypeError: Cannot read property 'init' of null error, because the needed native code wasn't generated.
Documentation
Description
When trying to call methods such as
Pushwoosh.init
,Pushwoosh.getHwid()
,Pushwoosh.addTags
, sometimes the following error arises:TypeError: Cannot read property 'init' of null
Bug severity
Normal
Steps to Reproduce
Initialize a new Expo react-native project with the following dependencies: "react-native": "0.74.1", "expo": "51.0.8", "pushwoosh-expo-plugin": "1.0.0" & "pushwoosh-react-native-plugin": "6.1.31"
Try and run any of the following methods:
Pushwoosh.init
,Pushwoosh.getHwid
,Pushwoosh.addTags
Your Pushwoosh React Native Plugin version
6.1.31
Last worked Pushwoosh React Native Plugin version (if any)
No response
Affected platforms
Affected OS versions and/or devices
Workaround
No response
Relevant log output
No response