尝试获取博览会通知令牌时出现错误

时间:2020-07-11 06:36:10

标签: react-native expo

当我尝试获取用户的expo推送令牌时,出现[TypeError:undefined不是对象(正在评估_PushTokenManager.default.getDevicePushTokenAsync”)错误。而且我还在Android设备上运行该应用。谁能帮我解决这个问题?

import * as Notifications from "expo-notifications";
import * as Permissions from "expo-permissions";

    const AppNavigator = () => {
      useEffect(() => {
        registerForPushNotifications();
      }, []);
    
      const registerForPushNotifications = async () => {
        const permission = await Permissions.askAsync(Permissions.NOTIFICATIONS);
        if (!permission.granted) {
          return;
        }
    
        const token = await Notifications.getExpoPushTokenAsync();
        expoPushTokensApi.register(token); // sending the token to the server
        console.log(token);
      };
    
    return {}
    }

0 个答案:

没有答案