Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ function App(): JSX.Element {
);

useEffect(() => {
// check if app was launched by tapping a native notification (cold start)
getPendingNotificationClick().then(data => {
if (data) handleNotificationClick({data});
});

notifee.getInitialNotification().then(initN => {
if (!initN?.notification) {
return;
Expand All @@ -101,6 +106,10 @@ function App(): JSX.Element {
);

const event = AppState.addEventListener('focus', () => {
// check if app was resumed by tapping a native notification (background state)
getPendingNotificationClick().then(data => {
if (data) handleNotificationClick({data});
});
if (backgroundClickedNotification) {
handleNotificationClick(backgroundClickedNotification);
}
Expand Down
3 changes: 3 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name=".custom.NotificationDismissReceiver"
android:exported="false" />
</application>
</manifest>
23 changes: 15 additions & 8 deletions android/app/src/main/java/com/nerimityreactnative/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
package com.nerimityreactnative

import android.content.Intent
import android.os.Bundle
import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
import com.facebook.react.defaults.DefaultReactActivityDelegate
import com.nerimityreactnative.custom.EmojiNotificationModule

class MainActivity : ReactActivity() {

/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
override fun getMainComponentName(): String = "NerimityReactNative"

/**
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
*/
override fun createReactActivityDelegate(): ReactActivityDelegate =
DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)

// called when app is launched from dead state via notification tap
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
intent?.let { EmojiNotificationModule.storeNotificationData(it) }
}

// called when app is already running (background) and notification is tapped
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
intent?.let { EmojiNotificationModule.storeNotificationData(it) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
import com.facebook.react.defaults.DefaultReactNativeHost
import com.facebook.soloader.SoLoader
import com.nerimityreactnative.custom.EmojiNotificationPackage

class MainApplication : Application(), ReactApplication {

Expand All @@ -19,6 +20,7 @@ class MainApplication : Application(), ReactApplication {
PackageList(this).packages.apply {
// Packages that cannot be autolinked yet can be added manually here, for example:
// add(MyReactNativePackage())
add(EmojiNotificationPackage())
}

override fun getJSMainModuleName(): String = "index"
Expand Down
Loading