GithubHelp home page GithubHelp logo

cometchat / cometchat-push-notification-app-react-native Goto Github PK

View Code? Open in Web Editor NEW
13.0 16.0 13.0 17.39 MB

Push Notification App for React Native (iOS/Android)

Home Page: https://www.cometchat.com

JavaScript 7.08% Java 11.99% Ruby 3.81% Objective-C 3.86% TypeScript 65.51% Objective-C++ 7.74%
calling chat messenger push-notifications video voice app react-native

cometchat-push-notification-app-react-native's Introduction

CometChat

React Native Enhanced Push Notifications (Beta) Sample App

The CometChat React Native Enhanced Push Notifications (Beta) Sample App is capable of handling push notifications for one-on-one (private), group messaging, and even call notifications. This sample app enables users to send and receive text messages, make and receive calls, and effectively displays push notifications for these interactions.

In our sample app:

  • Firebase Cloud Messaging (FCM) is used for displaying push notifications in Android
  • Apple Push Notification (APN) is used for displaying push notifications in iOS.

Note

If you use Push Notifications (Extension), please refer to our React Native Push Notifications (Extension) Sample app for guidance.

Pre-requisite

  1. Login to the CometChat Dashboard.
  2. Select an existing app or create a new one.
  3. Click on the Notifications section from the menu on the left.
  4. Enable Push Notifications by clicking on the toggle bar and configure the push notifications.
  5. Add credentials for FCM or APNs.

Run the Sample App

  1. Clone this repository.
  2. Run the following commands:
npm i -f
cd ios
pod install
cd ..
  1. If you're using Firebase Cloud Messaging (FCM), place the google-services.json & GoogleService-Info.plist files in the correct location as per FCM's documentation.
  2. Add your app credentials like APP_ID, REGION, and AUTH_KEY in the src/CONSTS.ts file.
  3. Also store the FCM_PROVIDER_ID (in case you're using FCM) or APNS_PROVIDER_ID (in case you're using APNs) in src/CONSTS.ts.
  4. Run the sample app
npm run android # To run the Android app
npm run ios # To run the iOS app
  1. Once the app is running on your device or emulator, login with a user.(The iOS app has to be run on a device. The Android app can run on emulator or device.)
  2. Allow the permission to display push notifications.
  3. Put the app in the background or terminate it.
  4. Send a message or call to the logged in user from another device.
  5. You should see a push notification for a message and call notification for a call.
  6. Tap on the notification to open the Sample app for message.
  7. Tap on accept/decline on call notification to initiate or decline call.

Help and Support

For issues running the project or integrating with our UI Kits, consult our documentation or create a support ticket or seek real-time support via the CometChat Dashboard.

cometchat-push-notification-app-react-native's People

Contributors

kaushikritik avatar ketanyekale avatar mathews-cometchat avatar mayur-bhandari avatar prathamesh-cometchat avatar prathameshtm avatar taruagarwal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cometchat-push-notification-app-react-native's Issues

Cannot receive notifications when the app was killed on iOS

On iOS, it works only when the app is in foreground and background but it fails to get notifications if it was killed.

It works perfectly fine on Android. Notifications can be received when the app is in foreground, background and quit state.

On iOS, it works only when the app is in foreground and background but it fails to get notifications if it was killed. This situation also happens in your sample app.

Expected behaviour: Notifications can be received when the app was killed on iOS

Notifications can be received when the app was killed on iOS

Reproduction

Everything the same in your master branch

Environment

Everything the same in your master branch

Possible Unhandled Promise Rejection (id: 0): TypeError: Cannot convert null value to object while registering FCM token

Describe the problem

Unable to register FCM token to comet-chat.

  useEffect(() => {
    //comet chat changes/additions
    var appSetting = new CometChat.AppSettingsBuilder()
      .subscribePresenceForAllUsers()
      .setRegion(Config.COMETCHAT_CONSTANTS.REGION)
      .build();
    //cometchat initialize
    CometChat.init(Config.COMETCHAT_CONSTANTS.APP_ID, appSetting)
      .then(() => {
        if (CometChat.setSource) {
          CometChat.setSource('ui-kit', Platform.OS, 'react-native');
        }
        CometChat.login(userData?.uuid, Config.COMETCHAT_CONSTANTS.AUTH_KEY).then((user) => {
          registerForFCM()
        }).catch(err => console.warn('login failed', err));
      })
      .catch(() => {
        return null;
      });

  }, []);

  const getPermissions = async () => {
    if (Platform.OS === 'android') {
      let granted = await PermissionsAndroid.requestMultiple([
        PermissionsAndroid.PERMISSIONS.CAMERA,
        PermissionsAndroid.PERMISSIONS.RECORD_AUDIO,
        PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,
        PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
      ]);
      if (granted !== PermissionsAndroid.RESULTS.GRANTED) {
        granted = await PermissionsAndroid.requestMultiple([
          PermissionsAndroid.PERMISSIONS.CAMERA,
          PermissionsAndroid.PERMISSIONS.RECORD_AUDIO,
          PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,
          PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
        ]);
      }
    }
  };

  const registerForFCM = async () => {
    const authStatus = await messaging().requestPermission();
    const enabled = authStatus === messaging.AuthorizationStatus.AUTHORIZED || authStatus === messaging.AuthorizationStatus.PROVISIONAL;
    if (enabled) {
      let FCMToken = await messaging().getToken();
      console.log('token:', FCMToken);
      if(FCMToken){
        let response = await CometChat.registerTokenForPushNotification(FCMToken)
        .then((res) => console.warn('res11', res))
        .catch(err => console.warn('err', err));
      console.log('register fro fcm :', response);
      }     
    }
  };

Reproduction

LOG token: egjsV2OCRUeUxEwbja2VXp:APA91bHaadVlogmOttqP6xWzmxWpqDW1jGWU9pE59YlxLUV08SUUGSQnFkTln_F4qauBYgxnQAKEUWTr2lA_OAO-uqmdPS5HYeV9-nKWcKlAC_qYqKNWhddKlXzFrRqwDD_qK0XgueXn
WARN Possible Unhandled Promise Rejection (id: 0):
TypeError: Cannot convert null value to object
TypeError: Cannot convert null value to object

Environment

** "react-native": "^0.70.1",**
"@cometchat-pro/react-native-chat": "^3.0.11"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.