Closed MitinDmytro closed 3 years ago
Hi all! After I locked my device, I showed full-screen notification, and I didn't receive any notification.
I used "@notifee/react-native": "^1.7.0" for display full-screen notification.
Steps to reproduce:
#### `showFullScreenNotification.js`: ```groovy export async function showFullScreenNotification() { const notification = { title: 'Duty Call', body: "", android: { channelId: 'full-screen', category: AndroidCategory.CALL, importance: AndroidImportance.HIGH, visibility: AndroidVisibility.PUBLIC, sound: 'default', fullScreenAction: { id: 'default', launchActivity: 'com.MyProjectName.CustomActivity' }, }, ios: { sound: 'default', } }; await notifee.deleteChannel(notification.android?.channelId || 'default') // Create a channel await notifee.createChannel({ id: notification.android?.channelId || 'default', name: notification.android?.channelId || 'default', importance: notification.android?.importance || AndroidImportance.HIGH, visibility: notification.android?.visibility || AndroidVisibility.PUBLIC, }); await notifee.displayNotification(notification); } ``` #### `index.js`: ```groovy import 'react-native-gesture-handler'; import React from 'react'; import { AppRegistry } from 'react-native'; import App from './App'; import { name as appName } from './app.json'; import DutyCall from './src/components/DutyCall/DutyCallScreen'; import notifee, { AndroidImportance } from '@notifee/react-native'; createChannels(); setBackgroundMessageHandler(); function createChannels() { notifee.createChannel({ id: 'default', name: 'default', sound: "default", vibration: true, importance: AndroidImportance.DEFAULT }); notifee.createChannel({ id: 'silent', name: 'silent', sound: undefined, vibration: true, importance: AndroidImportance.DEFAULT }); } function setBackgroundMessageHandler() { messaging().setBackgroundMessageHandler(async remoteMessage => { console.log('Background notification: ' + JSON.stringify(remoteMessage)); // =====>I didn't receive any notification in this setBackgroundMessageHandler during full-screen notification is showed. <===== }); } function MyComponent() { return ( ); } AppRegistry.registerComponent('custom', () => MyComponent); AppRegistry.registerComponent(appName, () => App); ``` #### `CustomActivity.java`: ```groovy package com.Shikma.ShikmaTesting; import android.view.View; import android.app.Activity; import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.ReactActivity; public class CustomActivity extends ReactActivity { @Override protected String getMainComponentName() { return "custom"; } } ``` #### `package.json`: ```json { "name": "MyProject", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "lint": "eslint .", "postinstall": "npx jetify", "build:ios": "react-native bundle --entry-file='index.js' --bundle-output='./ios/myproject/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'" }, "dependencies": { "@ingenuity-labs/react-native-api-client-wrapper": "^1.0.7", "@ingenuity-labs/react-native-async-storage-wrapper": "^1.0.3", "@notifee/react-native": "^1.7.0", "@react-native-community/checkbox": "^0.5.6", "@react-native-community/clipboard": "^1.5.1", "@react-native-community/geolocation": "^2.0.2", "@react-native-community/masked-view": "^0.1.10", "@react-native-community/netinfo": "^6.0.0", "@react-native-community/picker": "^1.8.1", "@react-native-community/progress-bar-android": "^1.0.4", "@react-native-community/progress-view": "^1.3.0", "@react-native-community/slider": "^3.0.3", "@react-native-community/toolbar-android": "0.1.0-rc.2", "@react-native-firebase/app": "^11.1.2", "@react-native-firebase/crashlytics": "^11.1.2", "@react-native-firebase/messaging": "^11.1.2", "@react-navigation/drawer": "^5.9.3", "@react-navigation/native": "^5.7.5", "@react-navigation/stack": "^5.9.2", "@types/jest": "^26.0.23", "buffer": "^6.0.3", "convert-string": "^0.1.0", "galio-framework": "^0.7.1", "lodash.debounce": "^4.0.8", "moment": "^2.29.1", "react": "^16.11.0", "react-chat-elements": "^10.12.0", "react-dom": "^17.0.1", "react-native": "^0.63.4", "react-native-android-immersive-mode": "^1.3.0", "react-native-animatable": "^1.3.3", "react-native-awesome-alerts": "^1.4.2", "react-native-background-fetch": "^4.0.2", "react-native-background-timer": "^2.4.1", "react-native-ble-manager": "^7.4.2", "react-native-ble-peripheral": "^2.0.1", "react-native-bluetooth-status": "^1.5.1", "react-native-collapsible": "^1.5.3", "react-native-date-picker": "^3.2.10", "react-native-default-preference": "^1.4.3", "react-native-device-info": "^8.1.2", "react-native-dropdown-picker": "^3.7.1", "react-native-elements": "^2.3.2", "react-native-exit-app": "^1.1.0", "react-native-fs": "^2.16.6", "react-native-gesture-handler": "^1.8.0", "react-native-i18n": "^2.0.15", "react-native-navigation-bar-color": "^2.0.1", "react-native-nfc-manager": "^3.3.0", "react-native-notification-sounds": "^0.5.3", "react-native-pdf": "^6.3.0", "react-native-raw-bottom-sheet": "^2.2.0", "react-native-really-awesome-button": "^1.6.0", "react-native-reanimated": "^1.13.1", "react-native-responsive-dimensions": "^3.1.1", "react-native-responsive-screen": "^1.4.2", "react-native-safe-area-context": "^3.1.8", "react-native-screens": "^2.11.0", "react-native-set-app-icon": "0.0.9", "react-native-side-menu-updated": "^1.2.1", "react-native-sound": "^0.11.0", "react-native-super-grid": "^4.0.3", "react-native-system-setting": "^1.7.5", "react-native-v8": "^0.63.4-patch.1", "react-native-vector-icons": "^6.7.0", "react-native-version-check": "^3.4.2", "react-native-volume-control": "^1.0.1", "react-navigation": "^4.4.3", "react-navigation-drawer": "^2.6.0", "react-navigation-stack": "^2.10.2", "react-onclickoutside": "^6.9.0", "react-redux": "^7.2.2", "redux": "^4.0.5", "rn-fetch-blob": "^0.12.0", "ts-jest": "^26.5.6", "typescript": "^4.2.4", "v8-android-jit": "^9.88.0" }, "devDependencies": { "@babel/core": "7.6.4", "@babel/runtime": "7.6.3", "@react-native-community/eslint-config": "0.0.5", "babel-jest": "24.9.0", "eslint": "6.6.0", "jest": "24.9.0", "jetifier": "^1.6.6", "metro-react-native-babel-preset": "0.57.0", "react-test-renderer": "16.9.0" }, "jest": { "preset": "react-native" } } ```
hey there, I think this is how full-screen notifications are designed - for example, if there's an incoming phone call, you don't want other notifications to appear over the top of it.
Hi all! After I locked my device, I showed full-screen notification, and I didn't receive any notification.
I used "@notifee/react-native": "^1.7.0" for display full-screen notification.
Steps to reproduce:
Code
Click To Expand
#### `showFullScreenNotification.js`: ```groovy export async function showFullScreenNotification() { const notification = { title: 'Duty Call', body: "", android: { channelId: 'full-screen', category: AndroidCategory.CALL, importance: AndroidImportance.HIGH, visibility: AndroidVisibility.PUBLIC, sound: 'default', fullScreenAction: { id: 'default', launchActivity: 'com.MyProjectName.CustomActivity' }, }, ios: { sound: 'default', } }; await notifee.deleteChannel(notification.android?.channelId || 'default') // Create a channel await notifee.createChannel({ id: notification.android?.channelId || 'default', name: notification.android?.channelId || 'default', importance: notification.android?.importance || AndroidImportance.HIGH, visibility: notification.android?.visibility || AndroidVisibility.PUBLIC, }); await notifee.displayNotification(notification); } ``` #### `index.js`: ```groovy import 'react-native-gesture-handler'; import React from 'react'; import { AppRegistry } from 'react-native'; import App from './App'; import { name as appName } from './app.json'; import DutyCall from './src/components/DutyCall/DutyCallScreen'; import notifee, { AndroidImportance } from '@notifee/react-native'; createChannels(); setBackgroundMessageHandler(); function createChannels() { notifee.createChannel({ id: 'default', name: 'default', sound: "default", vibration: true, importance: AndroidImportance.DEFAULT }); notifee.createChannel({ id: 'silent', name: 'silent', sound: undefined, vibration: true, importance: AndroidImportance.DEFAULT }); } function setBackgroundMessageHandler() { messaging().setBackgroundMessageHandler(async remoteMessage => { console.log('Background notification: ' + JSON.stringify(remoteMessage)); // =====>I didn't receive any notification in this setBackgroundMessageHandler during full-screen notification is showed. <===== }); } function MyComponent() { return (
);
}
AppRegistry.registerComponent('custom', () => MyComponent);
AppRegistry.registerComponent(appName, () => App);
```
#### `CustomActivity.java`:
```groovy
package com.Shikma.ShikmaTesting;
import android.view.View;
import android.app.Activity;
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.ReactActivity;
public class CustomActivity extends ReactActivity {
@Override
protected String getMainComponentName() {
return "custom";
}
}
```
#### `package.json`:
```json
{
"name": "MyProject",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint .",
"postinstall": "npx jetify",
"build:ios": "react-native bundle --entry-file='index.js' --bundle-output='./ios/myproject/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'"
},
"dependencies": {
"@ingenuity-labs/react-native-api-client-wrapper": "^1.0.7",
"@ingenuity-labs/react-native-async-storage-wrapper": "^1.0.3",
"@notifee/react-native": "^1.7.0",
"@react-native-community/checkbox": "^0.5.6",
"@react-native-community/clipboard": "^1.5.1",
"@react-native-community/geolocation": "^2.0.2",
"@react-native-community/masked-view": "^0.1.10",
"@react-native-community/netinfo": "^6.0.0",
"@react-native-community/picker": "^1.8.1",
"@react-native-community/progress-bar-android": "^1.0.4",
"@react-native-community/progress-view": "^1.3.0",
"@react-native-community/slider": "^3.0.3",
"@react-native-community/toolbar-android": "0.1.0-rc.2",
"@react-native-firebase/app": "^11.1.2",
"@react-native-firebase/crashlytics": "^11.1.2",
"@react-native-firebase/messaging": "^11.1.2",
"@react-navigation/drawer": "^5.9.3",
"@react-navigation/native": "^5.7.5",
"@react-navigation/stack": "^5.9.2",
"@types/jest": "^26.0.23",
"buffer": "^6.0.3",
"convert-string": "^0.1.0",
"galio-framework": "^0.7.1",
"lodash.debounce": "^4.0.8",
"moment": "^2.29.1",
"react": "^16.11.0",
"react-chat-elements": "^10.12.0",
"react-dom": "^17.0.1",
"react-native": "^0.63.4",
"react-native-android-immersive-mode": "^1.3.0",
"react-native-animatable": "^1.3.3",
"react-native-awesome-alerts": "^1.4.2",
"react-native-background-fetch": "^4.0.2",
"react-native-background-timer": "^2.4.1",
"react-native-ble-manager": "^7.4.2",
"react-native-ble-peripheral": "^2.0.1",
"react-native-bluetooth-status": "^1.5.1",
"react-native-collapsible": "^1.5.3",
"react-native-date-picker": "^3.2.10",
"react-native-default-preference": "^1.4.3",
"react-native-device-info": "^8.1.2",
"react-native-dropdown-picker": "^3.7.1",
"react-native-elements": "^2.3.2",
"react-native-exit-app": "^1.1.0",
"react-native-fs": "^2.16.6",
"react-native-gesture-handler": "^1.8.0",
"react-native-i18n": "^2.0.15",
"react-native-navigation-bar-color": "^2.0.1",
"react-native-nfc-manager": "^3.3.0",
"react-native-notification-sounds": "^0.5.3",
"react-native-pdf": "^6.3.0",
"react-native-raw-bottom-sheet": "^2.2.0",
"react-native-really-awesome-button": "^1.6.0",
"react-native-reanimated": "^1.13.1",
"react-native-responsive-dimensions": "^3.1.1",
"react-native-responsive-screen": "^1.4.2",
"react-native-safe-area-context": "^3.1.8",
"react-native-screens": "^2.11.0",
"react-native-set-app-icon": "0.0.9",
"react-native-side-menu-updated": "^1.2.1",
"react-native-sound": "^0.11.0",
"react-native-super-grid": "^4.0.3",
"react-native-system-setting": "^1.7.5",
"react-native-v8": "^0.63.4-patch.1",
"react-native-vector-icons": "^6.7.0",
"react-native-version-check": "^3.4.2",
"react-native-volume-control": "^1.0.1",
"react-navigation": "^4.4.3",
"react-navigation-drawer": "^2.6.0",
"react-navigation-stack": "^2.10.2",
"react-onclickoutside": "^6.9.0",
"react-redux": "^7.2.2",
"redux": "^4.0.5",
"rn-fetch-blob": "^0.12.0",
"ts-jest": "^26.5.6",
"typescript": "^4.2.4",
"v8-android-jit": "^9.88.0"
},
"devDependencies": {
"@babel/core": "7.6.4",
"@babel/runtime": "7.6.3",
"@react-native-community/eslint-config": "0.0.5",
"babel-jest": "24.9.0",
"eslint": "6.6.0",
"jest": "24.9.0",
"jetifier": "^1.6.6",
"metro-react-native-babel-preset": "0.57.0",
"react-test-renderer": "16.9.0"
},
"jest": {
"preset": "react-native"
}
}
```