带有 FCM / APNs 的世博会通知 - IOS 应用程序在生产中崩溃

问题描述 投票:0回答:0

在 testfligh 中创建 ios 构建和测试时在 expo 项目中集成用于推送通知的 firebase 消息传递后,应用程序在打开应用程序时崩溃(适用于 Android 设备但在 ios 设备上出现问题)

首先,我在 FCM 中创建了 peoject,并为 IOS.Library 使用 p8 身份验证令牌,用于推送通知 -

  "@react-native-firebase/app": "^17.3.2", "@react-native-firebase/messaging": "^17.3.2",

我还在我的 app.json 文件中添加了 .plist 文件

"config": { "googleServicesFile": "./GoogleService-Info.plist" }

这是我的 App.tsx 文件

import React, { useEffect } from "react";
import { Alert, StyleSheet } from "react-native";
import messaging from "@react-native-firebase/messaging";
import Navigation from "./src/navigation/Navigation";
import axios from "axios";
import { Provider } from "react-redux";
import store from "./src/redux/configureStore";
import { PersistGate } from "redux-persist/integration/react";
import "react-native-gesture-handler";
import { persistStore } from "redux-persist";
import Toast from "react-native-toast-message";
export default function App() {
  let persistor = persistStore(store);
  const requestUserPermission: any = async () => {
    const authStatus = await messaging().requestPermission();
    const enabled =
      authStatus === messaging.AuthorizationStatus.AUTHORIZED ||
      authStatus === messaging.AuthorizationStatus.PROVISIONAL;

    if (enabled) {
      console.log("Authorization status:", authStatus);
    }
  };
  useEffect(() => {
    if (requestUserPermission()) {
      messaging()
        .getToken()
        .then((token) => {
          console.log("token--------------", token);
        });
    } else {
      console.log("failed token status========");
    }
    messaging()
      .getInitialNotification()
      .then(async (remoteMessage) => {
        if (remoteMessage) {
          console.log(
            "Notification caused app to open from quit state:",
            remoteMessage.notification
          );
        }
      });
    messaging().onNotificationOpenedApp((remoteMessage) => {
      console.log(
        "Notification caused app to open from background state:",
        remoteMessage.notification
      );
    });
    messaging().setBackgroundMessageHandler(async (remoteMessage) => {
      console.log("Message handled in the background!", remoteMessage);
    });
    const unsubscribe = messaging().onMessage(async (remoteMessage) => {
      Alert.alert("A new FCM message arrived!", JSON.stringify(remoteMessage));
    });
    return unsubscribe;
  }, []);
  return (
    <>
      <Provider store={store}>
        <PersistGate loading={null} persistor={persistor}>
          <Navigation />
        </PersistGate>
      </Provider>
      <Toast />
    </>
  );
}

我为 Android 设备创建了开发版本并对其进行了测试,它正在运行。如何为 ios 设备测试此服务?我直接创建了生产构建,我想在创建生产构建之前测试它。

注意-我没有使用 Xcode

notifications firebase-cloud-messaging apple-push-notifications push
© www.soinside.com 2019 - 2024. All rights reserved.