4

I'm using Onesignal for push notifications but am stuck in an error and could not find the solution for many days.

OneSignal SDK Configuration:

  1. I configured the Google Android (FCM) Configuration with Firebase Server Key and Firebase Sender ID at Onesignal and selected the React Native/Expo SDK and copied the APP ID.

Expo SDK Setup:

  1. I have Expo Managed Workflow so I run the command

expo install onesignal-expo-plugin

  1. then I executed the command

yarn add react-native-onesignal

  1. Added the below code into App.json

{ "plugins": [ "onesignal-expo-plugin", { "mode": "development", }] }

  1. After that import react-native-onesignal and used APP ID in useEffect into reuqired JS

import OneSignal from 'react-native-onesignal';

useEffect(() => { OneSignal.setAppId("Pasted Copied APP ID here"); }, []);

  1. After that Run the Command

expo prebuild

but getting error

TypeError: Cannot read property 'smallIcons' of undefinedn at withSmallIcons (\node_modules\onesignal-expo-plugin\build\onesignal\withOneSignalAndroid.js)

now getting this error on all console commands related to this react-native project.

I configured Onesignal through the below documentation https://documentation.onesignal.com/docs/react-native-expo-sdk-setup

1 Answer 1

7

I solved it. actually, the error was occurring in the below code

"plugins": [
        "onesignal-expo-plugin",
        {
          "mode": "development"
        }
    ]

adding the extra Square brackets [ ] solved the "Cannot read property 'smallIcons' of undefined" problem

"plugins": [
      [
        "onesignal-expo-plugin",
        {
          "mode": "development"
        }
      ]
    ]
Sign up to request clarification or add additional context in comments.

1 Comment

That’s weird because that code is added automatically with only one pair of brackets. Thank you for the solution!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.