标签: react-native-fcm

ld:找不到-lFirebaseCore clang的库:错误:链接器命令失败,退出代码为1(使用-v查看调用)

我使用react-native-fcm远程推送通知,但它给出了这个错误:

ld:找不到-lFirebaseCore clang的库:错误:链接器命令失败,退出代码为1(使用-v查看调用)

荚:

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

target 'SefrTaSad' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for SefrTaSad

  pod 'Firebase'
  pod 'Firebase/Messaging'

end
Run Code Online (Sandbox Code Playgroud)

Podfile.lock:

PODS:
  - Firebase (5.5.0):
    - Firebase/Core (= 5.5.0)
  - Firebase/Core (5.5.0):
    - Firebase/CoreOnly
    - FirebaseAnalytics (= 5.1.0)
  - Firebase/CoreOnly (5.5.0):
    - FirebaseCore (= 5.1.0)
  - Firebase/Messaging (5.5.0): …
Run Code Online (Sandbox Code Playgroud)

xcode ios firebase react-native react-native-fcm

10
推荐指数
1
解决办法
8364
查看次数

在 React-Native 中获取 FCM 令牌

在我的 React-Native 应用程序中,我必须使用 firebase 通知。所以我创建了这个库。我是否以正确的方式做到了这一点?我如何测试它以检查它是否正常工作?我想要的是在这里返回 FCM 令牌。

/** Firebase Cloud Messaging Methods */
import firebase from 'react-native-firebase';

const getToken = async () => {
  try {
    const token = await firebase.messaging().getToken();
    if (token) return token;
  } catch (error) {
    console.log(error);
  }
};

const getFCMToken = async () => {
  try {
    const authorized = await firebase.messaging().hasPermission();
    const fcmToken = await getToken();

    if (authorized) return fcmToken;

    await firebase.messaging().requestPermission();
    return fcmToken;
  } catch (error) {
    console.log(error);
  }
};

export { getFCMToken };
Run Code Online (Sandbox Code Playgroud)

firebase react-native react-native-fcm

9
推荐指数
2
解决办法
3万
查看次数

React-native FCM:当应用程序处于后台或被杀时,无法访问通知数据

我正在尝试使用firebase云消息传递和反应本机应用程序使反应本机fcm工作.

我主要关注Android

react-native@0.48.0
react-native-fcm@10.0.2
OS: Android - Emulator - 7.0.2
Run Code Online (Sandbox Code Playgroud)

当我的应用程序处于前台时,它的工作正常,我在此功能中收到数据

FCM.on(FCMEvent.Notification, async (notif) => {

我可以处理一切

图片

但是当应用程序处于后台时,会收到通知,但是当我点击横幅时,应用程序进入前台,触发相同的功能,但是notif对象不同,并且不包含我的数据.

图片

当应用程序被杀死时,也会收到通知,但是当我点击横幅时,应用程序启动, FCM.getInitialNotification() 触发,并且我的notif对象也不包含数据,行为与后台相同

图片

我正在使用firebase web界面的node-gcm库测试消息的格式,但没有任何作用.

这是我的消息示例,但我尝试了大量的组合:

let message = new gcm.Message({
    priority: 'high',
    content_available: true,
    timeToLive: 3,
    data: {
        key1: 'message1',
        key2: 'message2'
    },
    notification: {
        title: "Hello, World",
        icon: "ic_launcher",
        body: "This is a notification that will be displayed if your app is in the background."
    },
    custom_notification: {
        key1: 'message1',
        key2: 'message2'
    }

});
Run Code Online (Sandbox Code Playgroud)

在这些情况下,我该如何继续发送和接收数据?因为让我抓狂.

如果您需要更多数据,请索取:)

谢谢!!

push-notification android-notifications react-native firebase-cloud-messaging react-native-fcm

7
推荐指数
1
解决办法
2022
查看次数

在应用程序处于前台或关闭状态时收到推送通知时的正确导航方式

对于使用反应导航的所有人员来说这是一个普遍的问题,以下是我的导航结构

export const createRootNavigator = (signedIn = false) => {
  return StackNavigator({
      Login: screen: Login,
      Welcome: screen: Welcome,
      Loading: screen: Loading,
      SignedIn: screen:  SignedIn,
   });
};

export const SignedIn = TabNavigator ({
    Home: screen: HomeNavigation, 
    FeedBack: screen: FeedBackNavigation, 
    Search: screen: SearchNavigation, 
    Me: screen: ProfileNavigation,  
});
Run Code Online (Sandbox Code Playgroud)

当应用程序处于前台或关闭状态时,我正在使用“ react-native-fcm”接收通知。收到通知后,如何构造代码以导航到特定屏幕?我应该在每个屏幕上订阅onNotification,然后导航到特定屏幕还是将其放置在集中位置?有人解决过吗?示例代码会很棒

软件版本:

反应导航1.0.0-beta.26

反应本色0.49.3

react-native react-navigation react-native-fcm

6
推荐指数
1
解决办法
4870
查看次数

React-Native Android FCM:没有获得令牌

我在我的React-Native应用程序中使用react-native-fcm.我使用下面的方法来获取推送的设备令牌.

FCM.getFCMToken().then((token) => {
    alert('FCM Token: ' + token);
    console.log(token);           
});
Run Code Online (Sandbox Code Playgroud)

问题是,我在iPhone应用程序中获得了一个令牌,但是当我在Android中尝试时,该方法未被调用.

我遵循react-native-fcm建议的每一步.任何人都可以帮我解决这个问题吗?

android push-notification react-native react-native-fcm

5
推荐指数
0
解决办法
1064
查看次数

在应用程序被杀或在react-native-fcm中的后台显示以JSON格式显示的fcm通知消息

我正在使用react-native-fcm库为Android设备.当我的应用程序运行时,我正在收到正确的通知,但是当我的应用程序在后台或被杀时,我收到的JSON格式的通知数据类似于我在这里分享的图像.

在此输入图像描述

componentDidMount() {
        // iOS: show permission prompt for the first call. later just check permission in user settings
        // Android: check permission in user settings
        FCM.requestPermissions().then(()=>console.log('granted')).catch(()=>console.log('notification permission rejected'));
        /*FCM.getFCMToken().then(token => {
            console.log('Token',token)
            // store fcm token in your server
        });*/
        this.notificationListener = FCM.on(FCMEvent.Notification, async(notif) => {
            console.log('FCM notification', notif)
            this.sendRemote(notif)
        });

        // initial notification contains the notification that launchs the app. If user launchs app by clicking banner, the banner notification info will be here rather than through FCM.on …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-android react-native-fcm

5
推荐指数
0
解决办法
751
查看次数