Android 博览会。通知不会弹出
Android 博览会。通知不会弹出,android,push-notification,notifications,expo,expo-notifications,Android,Push Notification,Notifications,Expo,Expo Notifications,“世博会”:“^39.0.0”/图书馆-世博会通知 自从使用新的API以来,我一直面临着各种各样的问题。我修复了图标、在apk中接收通知和处理程序的问题,现在我找不到这个问题的答案 我有3部手机三星Galaxy S9+带安卓10,小米红米4x带安卓7.12 N2G47H MIUI 10 Global 9.6.27和小米红米Note 4 Global安卓7.0 nrd90m MIUI Global 11.0.2 三星Galaxy S9+。使用当前配置,我收到通知 尽管它应该是优秀的: 震动+ 声
“世博会”:“^39.0.0”
/图书馆-世博会通知
自从使用新的API以来,我一直面临着各种各样的问题。我修复了图标、在apk中接收通知和处理程序的问题,现在我找不到这个问题的答案
我有3部手机三星Galaxy S9+带安卓10
,小米红米4x带安卓7.12 N2G47H MIUI 10 Global 9.6.27
和小米红米Note 4 Global安卓7.0 nrd90m MIUI Global 11.0.2
三星Galaxy S9+。使用当前配置,我收到通知
尽管它应该是优秀的:
- 震动+
- 声音+
- 收到通知时弹出窗口+
- 振动-在已发布和apk(独立)版本中均不起作用
- 声音+
- 收到通知时弹出窗口+
{
"expo": {
"name": "qwert",
"slug": "qwert",
"version": "1.1.2",
"orientation": "portrait",
"icon": "./src/assets/images/logo1024.png",
"scheme": "myapp",
"userInterfaceStyle": "automatic",
"privacy": "unlisted",
"splash": {
"image": "./src/assets/images/splashScreen.png",
"resizeMode": "contain",
"backgroundColor": "#f1f0f0"
},
"android": {
"package": "com.qwert.app",
"googleServicesFile": "./google-services.json",
"versionCode": 1,
"useNextNotificationsApi": true
},
"notification": {
"icon": "./src/assets/images/VIAicon96.png",
"color": "#8edcd5",
"androidMode": "collapse"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
},
"web": {
"favicon": "./assets/images/favicon.png"
},
"description": ""
}
}
我的权限/配置:
import Constants from 'expo-constants';
import * as Notifications from 'expo-notifications';
import * as Permissions from 'expo-permissions';
import { Platform } from 'react-native';
Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowAlert: true,
shouldPlaySound: true,
shouldSetBadge: true,
}),
});
export const registerForPushNotificationsAsync = async () => {
let token;
if (Constants.isDevice) {
const { status: existingStatus } = await Permissions.getAsync(
Permissions.NOTIFICATIONS,
);
let finalStatus = existingStatus;
if (existingStatus !== 'granted') {
const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);
finalStatus = status;
}
if (finalStatus !== 'granted') {
console.log('Failed to get push token for push notification!');
return;
}
token = (await Notifications.getExpoPushTokenAsync()).data;
console.log(token);
} else {
console.log('Must use physical device for Push Notifications');
}
if (Platform.OS === 'android') {
Notifications.setNotificationChannelAsync('default', {
name: 'default',
importance: Notifications.AndroidImportance.MAX,
vibrationPattern: [0, 250, 250, 250],
lightColor: '#FF231F7C',
});
}
// eslint-disable-next-line consistent-return
return token;
};
此外,在使用所有这些的地方:
useEffect(() => {
const handleNotification = async () => {
await getPermitsAndIntegrateIntoApp(store); // works great
};
const setPersistDataToStore = async () => {
const EXPO_PUSH_TOKEN = await registerForPushNotificationsAsync();
const qwertyyy = await getConfig(Constants.deviceId, EXPO_PUSH_TOKEN);
store.setQwerrt(config.destinations);
};
setPersistDataToStore();
Notifications.addNotificationReceivedListener(handleNotification);
return () => Notifications.removeAllNotificationListeners();
}, [store]);
在所有3部手机上,我都有处理通知的逻辑(发送请求、更新存储和应用程序上的更新屏幕)。它工作正常
如何自动配置显示推送通知的权限?如何在小米身上启用振动?我终于找到了答案。 告诉我们 那 告诉我们如何让用户设置通知的权限 我还是不知道小米为什么不振动