世博会推送通知不会唤醒安卓上的锁屏

时间:2021-05-18 08:53:17

标签: react-native push-notification expo

SDK 版本:41.0.1 平台(Android/iOS/web/all):Android

嗨,我遇到了博览会推送通知服务的问题。一切正常,但有一件事,通知不会唤醒安卓设备的锁屏。它适用于 ios。

我正在使用文档中的零食,这是我的代码:

NotificationProvider.TS

<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
import Constants from 'expo-constants';
import * as Notifications from 'expo-notifications';
import { Platform } from 'react-native';
import React from 'react';

export async function registerForPushNotificationsAsync() {
  let token;
  if (Constants.isDevice) {
    const { status: existingStatus } = await Notifications.getPermissionsAsync();
    let finalStatus = existingStatus;
    if (existingStatus !== 'granted') {
      const { status } = await Notifications.requestPermissionsAsync();
      finalStatus = status;
    }
    if (finalStatus !== 'granted') {
      alert('Failed to get push token for push notification!');
      return;
    }
    token = (await Notifications.getExpoPushTokenAsync()).data;
    console.log(token);
  } else {
    alert('Must use physical device for Push Notifications');
  }

  if (Platform.OS === 'android') {
    await Notifications.setNotificationChannelAsync('Requêtes', {
      name: 'Requêtes',
      importance: Notifications.AndroidImportance.MAX,
      vibrationPattern: [0, 250, 250, 250],
      lightColor: '#FF231F7C',
      lockscreenVisibility: Notifications.AndroidNotificationVisibility.PUBLIC,
      enableLights: true,
    });
  }

  return token;
}

import numpy as np

datatemp = np.loadtxt("estat_sdg_07_20.tsv", delimiter =",",skiprows=1,dtype=str)
    
data =  datatemp.read().replace(':','nan')

在互联网上没有找到任何解决方案。有没有人遇到过同样的问题?

1 个答案:

答案 0 :(得分:0)

这是标准的安卓行为,要在收到通知时唤醒锁屏,用户需要在手机设置中手动启用此功能