wix / react-native-notifications

React Native Notifications
MIT License
3.23k stars 763 forks source link

Suggestion - documentation update #1041

Open BTrottAtWork opened 3 months ago

BTrottAtWork commented 3 months ago

A helpful tip for android implementation if your react-native activity is not the same activity as the activity designated as your launch activity is to make sure you forward your intent extras to the activity that runs your react-native bundle.

A good example is if your launch activity is a splash screen which then sends the user to your MainActivity, which runs your react-native bundle. In this case you will need to send your splash activity's intent extras to your Main Activity's intent or react-native-notifications will not have access to the notification payload via the getInitialNotification function, so things like deep linking will not be possible.

Example:

 <activity
            android:name=".SplashActivity"
            android:theme="@style/SplashTheme"
            android:label="@string/app_name"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
                <action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
            </intent-filter>
        </activity>

onCreate of SplashActivity:

        Intent intent = new Intent(this, MainActivity.class);
        intent.putExtras(this.getIntent());
        startActivity(intent);
oxilor commented 2 months ago

@BTrottAtWork Thank you! I thought getInitialNotification does not work. Agree, it should be documented.