React Native Integration for Mapp Cloud
Acknowledgments
iOS: Mapp plugin n support iOS10 and above
Android: Mapp plugin support for Android 21 (Lollipop) and above
Prerequisites
Required React and ReactNative versions
"react": "18.2.0"
"react-native": "0.73.4"
Installation
Use command
npm install https://github.com/MappCloud/React-native-plugin.git --save
or
npm install react-native-mapp-plugin --save
Integration
Download plugin locally.
Add it as dependency to your package.json
yarn install or npm
Android Manually integration for the old versions
Open up `android/app/src/main/java/[...]/MainActivity.java`
Add `import com.reactlibrary.RNMappPluginPackage;` to the imports at the top of the file
Add `new RNMappPluginPackage()` to the list returned by the `getPackages()` method
2. Append the following lines to `android/settings.gradle`:
include ':react-native-mapp-plugin'
project(':react-native-mapp-plugin').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-mapp-plugin/android')
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
compile project(':react-native-mapp-plugin')
Android Setup:
Setup Firebase on Firebase message console Step A: Enable Firebase Cloud Messaging for Mapp Cloud
Add a plugin in build.Gradle
apply plugin: 'com.google.gms.google-services'
if use Geo add permissions in manifests(Optional only for geolocation)
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /
iOS
1) Install pods
cd ios && pod install
this should install automatically pod
2) Add the following capabilities for your application target:
- Push Notification
- Background Modes > Remote Notifications
- Background Modes > Location updates
3) Create a plist `AppoxeeConfig.plist` and include it in your application’s target:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>inapp</key>
<dict>
<key>custom_fields</key>
<array>
<string>customString</string>
<string>customNumber</string>
<string>customDate</string>
</array>
<key>media_timeout</key>
<integer>5</integer>
</dict>
<key>sdk</key>
<dict>
<key>app_id</key>
<string>your app id</string>
<key>dmc_system_id</key>
<integer>your dmc id</integer>
<key>sdk_key</key>
<string>your sdk key</string>
<key>is_eu</key>
<true/>
<key>open_landing_page_inside_app</key>
<false/>
<key>jamie_url</key>
<string>your inapp server url</string>
<key>apx_open_url_internal</key>
<string>YES</string>
</dict>
</dict>
</plist>
4) If using Rich notifications follow instructions from:
Rich Push Notifications Integration for iOS
5)In order to execute action from buttons or message body the following code needs to be added at AppDelegate file:
#import <RNMappPlugin/RNMappEventEmmiter.h>
// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries
(
void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
[[Appoxee shared] didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler andNotifyCompletionWithBlock:^(NSError * _Nullable appoxeeError, id _Nullable data) {
}];
return [super application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}