react-native-acoustic-mobile-push-beta

3.9.33 • Public • Published

react-native-acoustic-mobile-push-beta

Main Campaign plugin required for mobile push features.

Plugin Dependencies

None

Install

  1. Add react-native-acoustic-mobile-push-beta to the project.
yarn add react-native-acoustic-mobile-push-beta
npm i react-native-acoustic-mobile-push-beta
  1. Edit App.js to include the following two lines after the existing import statements:
import { NativeModules } from 'react-native';
const { RNAcousticMobilePush } = NativeModules;
RNAcousticMobilePush.requestPushPermission();

Alternatively, you can import the SDK into the component you need.

Update CampaignConfig.json

After the plugin is installed, 'CampaignConfig.json' file will be created if not found. Example screenshot of the file and the json properties:

Recipes on how to configure the Campaign SDK for iOS/android platforms:

https://developer.goacoustic.com/acoustic-campaign/recipes/configure-mobile-sdks-ios

https://developer.goacoustic.com/acoustic-campaign/recipes/configure-mobile-sdks-android

For production plugin, set "useRelease" to true, false uses beta build version. Note: Beta build plugin ends with '-beta'.

  "useRelease": true,

For iOS Campaign SDK version, update "iOS"

  "iOSVersion": "x.x.x",

For android Campaign SDK version, update "androidVersion"

  "androidVersion": "x.x.x",

Run node.js command from project's folder to automatically apply all updates in the json file

node node_modules/react-native-acoustic-mobile-push/postinstall.js ./

Set up your Android project

  1. Copy your google-services.json file with your Google-provided FCM credentials to your android project folder: android/app/google-services.json.
  2. Edit 'CampaignConfig.json' file 'android' section and fill in the appKeyandbaseUrl` provided by your account team.
"baseUrl": "https://mobile-sdk-lib-XX-Y.brilliantcollector.com",
"appKey": {
"prod": "INSERT APP KEY HERE"
},
  1. Additionally, you should support location services. Add the following line to your build.gradle app file:
implementation 'com.google.android.gms:play-services-location:<play-services version>'
  1. Launch Android app.
npx react-native run-android

Set up your iOS project

  1. Open the iOS project in Xcode.
  2. Fix up the bundle ID and signing to use a bundle ID and profile with appropriate capabilities.
  3. Add the Push Notification capability to your project: Go to Signing & Capabilities, Click **+Capability **, and select Push Notification.
  4. Turn on the Location Updates background mode to your project: Go to Signing & Capabilities and check Location Updates checkbox.
  5. Add the MceConfig.json file in the project directory to the Xcode project to Application target and fill in the baseUrl and appKey provided by your account team.
    "baseUrl": "https://mobile-sdk-lib-XX-Y.brilliantcollector.com",
    "appKey": {
    "prod": "INSERT APP KEY HERE"
    },

Run iOS

Run 'pod install' from the App's ios folder.

pod install

Launch iOS app.

npx react-native run-ios

📘 Note:

The iOS Simulator is unable to handle push messages.

Optional: Integrating the iOS notification service

The iOS notification service requires separate provisioning. This plug-in is required if you need to access push received events, dynamic action categories, and media attachments.

  1. Add framework file AcousticMobilePushNotification.xcframeworkon your main target at the Frameworks, Libraries, and Embedded Content section.
  2. Make sure that on your main target Build Phases, there's only one Framework AcousticMobilePush.xcframework added on the Link Binary with Libraries and that both frameworks are present in the Embed Frameworks section.
  3. Add a new Notification Service Extension target:
    a. In your XCode project, go to the File menu and select New > Target. A dialog box opens.
    b. In the dialog box, select iOS at the top and then select Notification Service Extension.
    c. Select Next, enter the extension name NewAppNotificationService, and choose **Objective-C **as
    Language.
    d. Click Finish. If a dialog box opens, select Activate. The new target is added to the project. Xcode created a new folder with files in it.
    e. Change the new target bundle identifier prefix and use .notification.
    f. Verify that the new target has the same iOS version as the application target. SDK minimum supported version is 12.0.
    g. Add the MceConfig.json file to the Notification Service target. Open the file and check the notification service target membership in the Target Membership of the File Inspector in the Xcode pane.
    h. Add -ObjC to the Other Linker Flags build options for the Notification Service.
    d. Add App Group capability to both your notification service extension and Application target. Be sure to use the same app group as the main application.
    e. Add the Keychain Sharing capability to both your notification service extension and Application target. Be sure to use the same value as the main application.
    f. Replace the contents of NotificationService.m and NotificationService.h with the following code:
// NotificationService.h
#import <UserNotifications/UserNotifications.h>
#import <AcousticMobilePushNotification/AcousticMobilePushNotification.h>

@interface NotificationService : MCENotificationService

@end
// NotificationService.m
#import "NotificationService.h"

@implementation NotificationService

@end

Add other Campaign features

  1. To add other features, update the 'plugins' section in the 'CampaignConfig.json' file. Below is default recommended settings:
 "plugins": {
    "Required Mobile-Push plugins": "<true/false>, enable or disable plugin",
    "react-native-acoustic-mobile-push-beta": true,
    "react-native-acoustic-mobile-push-ios-notification-service-beta": true,
    "react-native-acoustic-mobile-push-inapp-beta": true,
    "react-native-acoustic-mobile-push-inbox-beta": true,

    "Optional Mobile-Push plugins": "<true/false>, enable or disable plugin",
    "react-native-acoustic-mobile-push-action-menu-beta": true,
    "react-native-acoustic-mobile-push-beacon-beta": true,
    "react-native-acoustic-mobile-push-calendar-beta": true,
    "react-native-acoustic-mobile-push-displayweb-beta": true,
    "react-native-acoustic-mobile-push-geofence-beta": true,
    "react-native-acoustic-mobile-push-imagecarousel-beta": true,
    "react-native-acoustic-mobile-push-location-beta": true,
    "react-native-acoustic-mobile-push-snooze-beta": true,
    "react-native-acoustic-mobile-push-textinput-beta": true,
    "react-native-acoustic-mobile-push-wallet-beta": true
  },
  1. Run node.js command to automatically install from project folder
node node_modules/react-native-acoustic-mobile-push/postinstall.js ./

## Build the sample React-Native app

<https://github.com/go-acoustic/Acoustic-Mobile-Push-React-Native>

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
3.9.330latest

Version History

VersionDownloads (Last 7 Days)Published
3.9.330
3.9.3111
3.9.300
3.9.290
3.9.280
3.9.270
3.9.260
3.9.250
3.9.240
3.9.230
3.9.210
3.9.200
3.9.190
3.9.180
3.9.170
3.9.160
3.9.150
3.9.140
3.9.130
3.9.120
3.9.110
3.9.100
3.9.90
3.9.80
3.9.70
3.9.60
3.9.50
3.9.40
3.9.30
3.9.20
3.9.10
3.8.220
3.8.210
3.8.201
3.8.190
3.8.180
3.8.170
3.8.160
3.8.150
3.8.140
3.8.130
3.8.120
3.8.110
3.8.100
3.8.90
3.8.80

Package Sidebar

Install

npm i react-native-acoustic-mobile-push-beta

Weekly Downloads

12

Version

3.9.33

License

See license in ../../../license.txt

Unpacked Size

140 kB

Total Files

25

Last publish

Collaborators

  • ohernandezibm
  • changjieyang
  • benderrodriguezaco