GithubHelp home page GithubHelp logo

honzajerabek / mobile-messaging-react-native-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from infobip/mobile-messaging-react-native-plugin

0.0 0.0 0.0 69.52 MB

Mobile Messaging SDK plugin for React Native projects

Shell 0.62% JavaScript 19.04% Ruby 1.36% C++ 3.24% Objective-C 3.51% Java 49.55% Objective-C++ 1.87% Swift 19.82% Makefile 0.71% Starlark 0.28%

mobile-messaging-react-native-plugin's Introduction

Mobile Messaging SDK plugin for React Native

npm

Mobile Messaging SDK is designed and developed to easily enable push notification channel in your mobile application. In almost no time of implementation you get push notification in your application and access to the features of Infobip IP Messaging Platform. The document describes library integration steps for your React Native project.

Requirements

  • node (v16.10.0 or higher)
  • ruby (2.7.4)
  • React Native (v0.68.0)

For iOS project:

  • Xcode and Command Line Tools (13.2.1)
  • CocoaPods (v1.11.3)
  • Minimum deployment target 12.0

For Android project:

  • Android Studio (Bumblebee | 2021.1.1)
  • Gradle (v7.3.3)
  • Supported API Levels: 21 (Android 5.0 - Lollipop) - 31 (Android 12.0)

Quick start guide

This guide is designed to get you up and running with Mobile Messaging SDK plugin for React Native:

  1. Make sure to setup application at Infobip portal, if you haven't already.

  2. Add MobileMessaging plugin to your project, run in terminal:

    $ npm install infobip-mobile-messaging-react-native-plugin

    TypeScript's definitions are included into npm package

  3. Configure platforms

    • iOS

      Notice

      Starting from the 6.2.0 plugin version it's not mandatory to add use_frameworks! to the Podfile, check the Migration guide if you want to get rid of it.

      1. Run pod install from /ios folder (installs Mobile Messaging native SDK)
      2. Import following header #import <MobileMessaging/MobileMessagingPluginApplicationDelegate.h> and add [MobileMessagingPluginApplicationDelegate install]; into /ios/<ProjectName>/AppDelegate.m (this is required for OS callbacks such as didRegisterForRemoteNotifications to be intercepted by native MobileMessaging SDK)
          ...
          #import <MobileMessaging/MobileMessagingPluginApplicationDelegate.h>
      
          @implementation AppDelegate
      
          - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
          {
              [MobileMessagingPluginApplicationDelegate install];
              ...
          }
          ...
      1. Configure your project to support Push Notification as described in item 2 of iOS integration quick start guide
      2. Integrate Notification Service Extension into your app in order to obtain:
        • more accurate processing of messages and delivery stats
        • support of rich notifications on the lock screen
    • Android

      1. Following paths should be provided in .bash_profile

        export ANDROID_HOME=$HOME/Library/Android/sdk
        export PATH=$PATH:$ANDROID_HOME/emulator
        export PATH=$PATH:$ANDROID_HOME/tools
        export PATH=$PATH:$ANDROID_HOME/tools/bin
        export PATH=$PATH:$ANDROID_HOME/platform-tools
      2. Add 'com.google.gms:google-services' to android/build.gradle file

        buildscript {
           ...
           dependencies {
               ...
              //GMS Gradle plugin
              classpath 'com.google.gms:google-services:4.3.10'
           }
        }

        And add apply plugin: 'com.google.gms.google-services' at the end of your android/app/build.gradle in order to apply Google Services Gradle Plugin

      3. Add a Firebase configuration file (google-services.json) as described in Firebase documentation. Check Applying Firebase configuration in MobileMessaging SDK Guide for alternatives.

      Notice (check if you don't plan to use Geofencing):

      As long as Geofencing is automatically included to the plugin, it adds required geo permissions automatically. You can remove them from /android/app/src/main/AndroidManifest.xml by adding following:

      <manifest ... xmlns:tools="http://schemas.android.com/tools">
      ...
      <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" tools:node="remove"  />
      <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" tools:node="remove"  />
      <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" tools:node="remove"  />
      ...
      </manifest>
      

Initialization configuration

Initialize Mobile Messaging React Native plugin, provide application configuration in init method:

import { mobileMessaging } from 'infobip-mobile-messaging-react-native-plugin';

someMethod(): void {
   ...

           mobileMessaging.init(
                   {
                      applicationCode: '<your app code>',
                      ios: {
                         notificationTypes: ['alert', 'badge', 'sound'],
                      },
                   },
                   () => {
                      console.log('MobileMessaging started');
                   },
                   error => {
                      console.log('MobileMessaging error: ', error);
                   },
           );
}
expand to see TypeScript code

import { mobileMessaging } from 'infobip-mobile-messaging-react-native-plugin';

someMethod(): void {
   ...

           mobileMessaging.init(
                   {
                      applicationCode: '<your app code>',
                      ios: {
                         notificationTypes: ['alert', 'badge', 'sound'],
                      },
                   },
                   () => {
                      console.log('MobileMessaging started');
                   },
                   (error: MobileMessagingError) => {
                      console.log('MobileMessaging error: ', error);
                   },
           );
}

More details on SDK features and FAQ you can find on Wiki


NEXT STEPS: User profile


If you have any questions or suggestions, feel free to send an email to [email protected] or create an issue.

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.