TypeError: Cannot read property 'init' of null means the native Pushwoosh module is not present in the running app: the JavaScript layer is loaded, but there is no native module behind it. In an Expo project this usually happens because the Pushwoosh config plugin is not registered, or the native projects have not been regenerated.
1. Install both packages
expo install pushwoosh-expo-plugin
npm install pushwoosh-react-native-plugin --save
2. Register the config plugin in app.json / app.config.js, at the front of the plugins array. This is the step that actually wires up the native module — prebuild alone will not do it:
{
"expo": {
"plugins": [
["pushwoosh-expo-plugin", {
"mode": "development",
"ios": { "PW_API_TOKEN": "__YOUR_DEVICE_API_TOKEN__" },
"android": { "apiToken": "__YOUR_DEVICE_API_TOKEN__" }
}]
]
}
}
Also set android.package and android.googleServicesFile (path to your google-services.json) and ios.bundleIdentifier.
3. Regenerate the native projects
npx expo prebuild
4. Run a development build — Expo Go cannot load custom native modules, so you must build the app itself:
npx expo run:ios
npx expo run:android
Finally, check that initialisation happens in the root component of your app:
import Pushwoosh from 'pushwoosh-react-native-plugin';
Pushwoosh.init({ "pw_appid": "__YOUR_APP_ID__" });
Pushwoosh.register();
See the Expo integration guide for the full walkthrough.
Comments
0 comments
Please sign in to leave a comment.