Android Kill-State support for data-only notification #4242
-
I am trying to get notifications in any app state (foreground, background, killed). First I used notification part in notification json but it led to an issue which is when app is in background the notification is not displayed only appers in tray area. Then I used data part of notification. This time everything is good except when app is killed. I have console.log in my index.js setBackgroundMessageHandler but it is not called when notification is composed of only data part as I said. **
** **
** import App from "./App"; // registerRootComponent calls AppRegistry.registerComponent('main', () => App); messaging().setBackgroundMessageHandler(async (remoteMessage) => { registerRootComponent(App); **
** **
** import { StatusBar } from "expo-status-bar"; let cookieguid; remember = async () => { export default function App() { let webViewRef; useEffect(() => { useEffect(() => {
}, []); getCookie = async () => {
}; deleteSavedCookie = async () => { const loadingComp = ( return loading ? loadingComp : webviewComp; const styles = StyleSheet.create({ **
**
} **
**
Note: I want to use default channel for the notifications I want to send notifications to specific devies using their token |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
you are using version xyz ? this is on platform ? "killed" how exactly (describe the exact steps) ? The JSON you send via the javascript admin SDK is ? |
Beta Was this translation helpful? Give feedback.
-
The problem was android app when in debug when swiped up was getting killed by Android. I didn't know that. I know react concepts, some react-native concepts but don't know much about Android development that mislead me into thinking notifications did not work. When I build apk (release) notifications work as expected. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately this is vendor dependent as well. If you implement headless support the app may stay alive after being swiped away, on many vendors. If you send a visible notification it will show up even if your app is closed but you won't get to handle data key/values until the user interacts with the notification. There is a lot to learn in this area (and similar with iOS) unfortunately - sometimes it seems as much an art as a science |
Beta Was this translation helpful? Give feedback.
The problem was android app when in debug when swiped up was getting killed by Android. I didn't know that. I know react concepts, some react-native concepts but don't know much about Android development that mislead me into thinking notifications did not work. When I build apk (release) notifications work as expected.