5.0.1 • Published 1 month ago

com-infobip-plugins-mobilemessaging v5.0.1

Weekly downloads
76
License
Apache 2.0
Repository
github
Last release
1 month ago

Mobile Messaging SDK plugin for Cordova

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 Cordova project.

Requirements

  • Cordova 7.0+ (sudo npm install -g cordova)
  • npm (tested with 4.1.2)
  • node (tested with 7.5.0)

For iOS project:

  • Xcode 10
  • Carthage (brew install carthage)
  • Minimum deployment target 10.0
  • Ruby version 2.3.8

For Android project:

  • Android Studio
  • API Level: 14 (Android 4.0 - Ice Cream Sandwich)

For Huawei:

  • Android Studio
  • Installed AppGallery with HMS Core at device
  • API level: 19 (Android 4.4 - KitKat)

Quick start guide

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

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

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

    $ cordova plugin add com-infobip-plugins-mobilemessaging --save

    You can add typings if you are using TypeScript in yours project

    npm install --save-dev @types/mobile-messaging-cordova
    ionic cordova plugin add com-infobip-plugins-mobilemessaging --save
    npm install @ionic-native/mobile-messaging --save
  3. Configure platforms

    1. iOS: 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
    2. Android: add Firebase Sender ID via plugin variable in config.xml :
    <plugin name="com-infobip-plugins-mobilemessaging" spec="...">
        <variable name="ANDROID_FIREBASE_SENDER_ID" value="Firebase Sender ID" />
    </plugin>
  4. Configure Huawei build

    1. Configure <a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/android-config-agc-0000001050170137" target="_blank">Huawei application</a>
    2. Change `plaform/android/build.gradle` at the begging 
        ```gradle
            
            buildscript {
                repositories {
                    mavenCentral()
                    google()
                    jcenter()
                    maven { url 'http://developer.huawei.com/repo/' } // Added
                }
            
                dependencies {
                    classpath 'com.android.tools.build:gradle:3.3.0'
                    classpath 'com.huawei.agconnect:agcp:1.2.1.301' // Added
                }
            }
       
            allprojects {
                repositories {
                    google()
                    jcenter()
                    maven {url 'https://developer.huawei.com/repo/'} // Added
                }
                ...
            }
       
       ```    
    3. Change `plaform/android/app/build.gradle` at the begging 
        ```gradle
       
            apply plugin: 'com.android.application'
            apply plugin: 'com.huawei.agconnect' // Added
            
            dependencies {
                   implementation 'com.huawei.hms:push:5.0.0.300'
                   implementation('com.huawei.hms:location:5.0.0.300') // Add it if you will use Geofencing feature
            }
       
       ```
    4. Sign your app to provide config for <a href="https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/android-config-agc-0000001050170137#EN-US_TOPIC_0000001050170137__section193351110105114"  target="_blank">Generated Signing Certificate Fingerprint</a> at previous step.

    You can change plaform/android/app/build.gradle or write sign config to build.json

        ```gradle
       
           android {
    
               signingConfigs {
                   release {
                       storeFile file(<path to *.jks file>)
                       storePassword "<password>"
                       keyAlias "<alias>"
                       keyPassword "<password>"
                   }
               }
               buildTypes {
                   release {
                       signingConfig signingConfigs.release
                   }
                   debug {
                       signingConfig signingConfigs.release
                   }
               }
       
               ...
       
        ```
    5. Download `agconnect-services.json` from <a href="https://developer.huawei.com/consumer/ru/service/josp/agc/index.html"  target="_blank">AppGallery Connect </a> and copy it to `platforms/android/app`.
        
        a. Find your App from the list and click the link under Android App in the Mobile phone column.
        
        b. Go to Develop > Overview.
        
        c. In the App information area, Click `agconnect-services.json` to download the configuration file.
    6. Add [`Huawei App ID`](https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/android-config-agc-0000001050170137) via plugin variable in `config.xml` :   
        ```xml
        <plugin name="com-infobip-plugins-mobilemessaging" spec="...">
            <variable name="HUAWEI_SENDER_ID" value="Huawei App ID" />
        </plugin>
        ```       
        You can take this value from `agconnect-services.json`.
        
    7. Run `cordova build android --hms` to make build for HMS.
        
        **Note** that if you are developing / testing FCM and HMS at the same device then better to remove cache for installed app, remove app and after that install build with other push cloud. 
  5. Add code to your project to initialize the library after deviceready event with configuration options and library event listener:

    onDeviceReady: function() {
        ...
        MobileMessaging.init({
                applicationCode: '<your_application_code>',
                geofencingEnabled: '<true/false>',
                ios: {
                    notificationTypes: ['alert', 'badge', 'sound']
                },
                android: {
                    notificationIcon: <String; a resource name for a status bar icon (without extension), located in '/platforms/android/app/src/main/res/mipmap'>,
                    multipleNotifications: <Boolean; set to 'true' to enable multiple notifications>,
                    notificationAccentColor: <String; set to hex color value in format '#RRGGBB' or '#AARRGGBB'>
                }
            },
            function(error) {
                console.log('Init error: ' + error.description);
            }
        );
    
        MobileMessaging.register('messageReceived', 
            function(message) {
                console.log('Message Received: ' + message.body);
            }
        );
    
        ...
    }

    Add this code to app.module.ts::

    import { MobileMessaging } from '@ionic-native/mobile-messaging/ngx';
    
    ...
    
    @NgModule({
     ...
    
      providers: [
        ...
        MobileMessaging
        ...
      ]
      ...
    })
    export class AppModule { }

    Usage sample:

    import {Message, MobileMessaging, UserData} from '@ionic-native/mobile-messaging/ngx';
    
    ...
    
    @Component({
      selector: 'app-root',
      templateUrl: 'app.component.html',
      styleUrls: ['app.component.scss']
    })
    export class AppComponent {
      constructor(
        private platform: Platform,
        private splashScreen: SplashScreen,
        private statusBar: StatusBar,
        private mobileMessaging: MobileMessaging
      ) {
        this.initializeApp();
      }
    
    ...
    
      this.mobileMessaging.init({
        applicationCode: '<your_application_code>',
        geofencingEnabled: '<true/false>',
        ios: {
          notificationTypes: ['alert', 'badge', 'sound']
        },
        android: {
          notificationIcon: <String; a resource name for a status bar icon (without extension), located in '/platforms/android/app/src/main/res/mipmap'>,
          multipleNotifications: <Boolean; set to 'true' to enable multiple notifications>,
          notificationAccentColor: <String; set to hex color value in format '#RRGGBB' or '#AARRGGBB'>
       }}, (err) => {
         ...
       });
     
       this.mobileMessaging.register('messageReceived').subscribe((message: Message) => {
         ...
       });

Initialization configuration

MobileMessaging.init({
        applicationCode: <String; Infobip Application Code from the Customer Portal obtained in step 2>,
        ios: {
            notificationTypes: <Array; values: 'alert', 'badge', 'sound'; notification types to indicate how the app should alert user when push message arrives>
        },
        android: { // optional
            notificationIcon: <String; a resource name for a status bar icon (without extension), located in '/platforms/android/app/src/main/res/mipmap'>,
            multipleNotifications: <Boolean; set to 'true' to enable multiple notifications>,
            notificationAccentColor: <String; set to hex color value in format '#RRGGBB' or '#AARRGGBB'>
        },
        geofencingEnabled: <Boolean; set to 'true' to enable geofencing inside the library>, // optional
        messageStorage: <Object; message storage implementation>, // optional
        defaultMessageStorage: <Boolean; set to 'true' to enable default message storage implementation>, // optional
        notificationCategories: [ // optional
           {
               identifier: <String; a unique category string identifier>,
               actions: [
                   {
                       identifier: <String; a unique action identifier>,
                       title: <String; an action title, represents a notification action button label>,
                       foreground: <Boolean; to bring the app to foreground or leave it in background state (or not)>,
                       textInputPlaceholder: <String; custom input field placeholder>,
                       moRequired: <Boolean; to trigger MO message sending (or not)>,
                                               
                       // iOS only
                       authenticationRequired: <Boolean; to require device to be unlocked before performing (or not)>,
                       destructive: <Boolean; to be marked as destructive (or not)>,
                       textInputActionButtonTitle: <String; custom label for a sending button>,
                       
                       // Android only
                       icon:
                        <String; a resource name for a special action icon>
                   }
               ]   
           }
        ],
        privacySettings: { // optional
            carrierInfoSendingDisabled: <Boolean; defines if MM SDK should send carrier information to the server; false by default>,
            systemInfoSendingDisabled: <Boolean; defines if MM SDK should send system information to the server; false by default>,
            userDataPersistingDisabled: <Boolean; defines if MM SDK should persist User Data locally. Persisting user data locally gives you quick access to the data and eliminates a need to implement the persistent storage yourself; false by default>
        }
    },
    function(error) {
        console.log('Init error: ' + error.description);
    }
);

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

If you have any questions or suggestions, feel free to send an email to support@infobip.com or create an issue.
5.0.1

1 month ago

6.0.0-rc2

1 month ago

6.0.0-rc1

2 months ago

5.0.0

2 months ago

4.1.0

3 months ago

4.0.0

3 months ago

3.0.1

5 months ago

3.0.0-rc10

6 months ago

3.0.0-rc9

10 months ago

3.0.0-rc8

10 months ago

3.0.0-rc4

2 years ago

3.0.0-rc2

2 years ago

3.0.0

2 years ago

2.5.1

2 years ago

2.4.3

2 years ago

2.4.1

2 years ago

2.4.2

2 years ago

2.4.0

3 years ago

2.3.1

3 years ago

2.3.0

3 years ago

2.2.7

3 years ago

2.1.5

3 years ago

2.2.8

3 years ago

2.2.6

3 years ago

2.1.3

3 years ago

2.2.5

3 years ago

2.2.4

3 years ago

2.2.3

3 years ago

2.2.2

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.9.0

3 years ago

1.8.1

3 years ago

1.8.0

3 years ago

1.7.2

3 years ago

1.7.1

3 years ago

1.7.0

3 years ago

1.6.4

3 years ago

1.6.3

4 years ago

1.6.2

4 years ago

1.6.1

4 years ago

1.6.0

4 years ago

1.5.8

4 years ago

1.5.7

4 years ago

1.5.6

4 years ago

1.5.5

4 years ago

1.5.4

4 years ago

1.5.3

4 years ago

1.5.2

4 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.10

4 years ago

1.2.9

4 years ago

1.2.8

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.10.15

5 years ago

0.10.14

6 years ago

0.10.13

6 years ago

0.10.12

6 years ago

0.10.11

6 years ago

0.10.10

6 years ago

0.10.9

6 years ago

0.10.8

6 years ago

0.10.7

6 years ago

0.10.6

6 years ago

0.10.5

6 years ago

0.10.4

6 years ago

0.10.3

6 years ago

0.10.2

6 years ago

0.10.1

6 years ago

0.9.6

6 years ago

0.10.0

6 years ago

0.9.4

6 years ago

0.9.3

6 years ago

0.9.2

6 years ago

0.9.0

6 years ago

0.8.7

6 years ago

0.8.6

6 years ago

0.8.5

6 years ago

0.8.3

6 years ago