Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions kits/braze/braze-39/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Braze (formerly Appboy) Kit Integration

This repository contains the [Braze](https://www.braze.com/) integration for the [mParticle Android SDK](https://github.com/mParticle/mparticle-android-sdk).

## Example App

This repository contains an [example app](https://github.com/mparticle-integrations/mparticle-android-integration-appboy/tree/master/example) showing how to implement mParticle, Braze, and Firebase Cloud Messaging. The key changes you need to make to your app are below, and please also reference mParticle and Braze's documentation:

- [Instrumenting Push](https://docs.mparticle.com/developers/sdk/android/push-notifications)
- [Braze Documentation](https://docs.mparticle.com/integrations/braze/event)

## 1. Adding the integration

[See a full build.gradle example here](https://github.com/mparticle-integrations/mparticle-android-integration-appboy/blob/master/example/build.gradle)

1. The Braze Kit requires that you add Braze's Maven server to your buildscript:

```groovy
repositories {
maven { url "https://appboy.github.io/appboy-android-sdk/sdk" }
//Braze's library depends on the Google Support Library
google()
...
}
```

2. Add the kit dependency to your app's `build.gradle`:

```groovy
dependencies {
implementation 'com.mparticle:android-appboy-kit:5+'
}
```

## 2. Registering for Push

mParticle's SDK takes care of registering for push notifications and passing tokens or instance IDs to the Braze SDK. [Follow the mParticle push notification documentation](https://docs.mparticle.com/developers/sdk/android/push-notifications#register-for-push-notifications) to instrument the SDK for push registration. You can skip over [this section of Braze's documentation](https://www.braze.com/docs/developer_guide/platform_integration_guides/android/push_notifications/integration/#registering-for-push).

## 3. Displaying Push

[See a full example of an AndroidManifest.xml here](https://github.com/mparticle-integrations/mparticle-android-integration-appboy/blob/master/example/src/main/AndroidManifest.xml).

mParticle's SDK also takes care of capturing incoming push notifications and passing the resulting `Intent` to Braze's `BrazePushReceiver`. Follow the [mParticle push notification documentation](https://docs.mparticle.com/developers/sdk/android/push-notifications#display-push-notifications) to ensure you add the correct services and receivers to your app's AndroidManifest.xml.

## 4. Reacting to Push and Deeplinking

There are a wide variety of implementation options available in Braze to deeplink a user when they tap a notification. There are **two specific requirements** to ensure automatic deeplinking works as intended.

- `BrazePushReceiver`

Whereas up until now you should have nothing Braze-specific in your `AndroidManifest.xml`, using Braze's automatic deeplinking does require you to add their `BrazePushReceiver`. Note that you do not need to specify any Intent filters (for example to receive push tokens, since mParticle takes care of that). You just need to add the following:

```xml
<receiver android:name="com.braze.push.BrazePushReceiver" />
```

- `braze.xml`

For automatic deep-linking, you need to add a boolean resource named `com_braze_handle_push_deep_links_automatically`. This can be in any resource file, or you can name it `braze.xml`:

```xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="com_braze_handle_push_deep_links_automatically">true</bool>
</resources>
```

From here you should be able to successfully test push via Braze! Braze offers many client-side configurable options via xml resources and otherwise. Please see review the rest of [their documentation here](https://www.braze.com/docs/developer_guide/platform_integration_guides/android/push_notifications/integration/#step-3-add-deep-links) for more information.

## License

[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)
72 changes: 72 additions & 0 deletions kits/braze/braze-39/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
buildscript {
ext.kotlin_version = '2.0.20'
if (!project.hasProperty('version') || project.version.equals('unspecified')) {
project.version = '+'
}

repositories {
google()
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.4'
classpath 'com.mparticle:android-kit-plugin:' + project.version
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

plugins {
id "org.sonarqube" version "3.5.0.2730"
id "org.jlleitschuh.gradle.ktlint" version "13.0.0"
}

sonarqube {
properties {
property "sonar.projectKey", "mparticle-android-integration-appboy"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will overwrite the report from the other kit with the same name. I would suggest to change the name

property "sonar.organization", "mparticle"
property "sonar.host.url", "https://sonarcloud.io"
}
}

apply plugin: 'org.jlleitschuh.gradle.ktlint'
apply plugin: 'kotlin-android'
apply plugin: 'com.mparticle.kit'

android {
namespace 'com.mparticle.kits.appboy'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both the kits can't be published with the same namespace.

buildFeatures {
buildConfig = true
}
defaultConfig {
minSdkVersion 21
}
lint {
// Workaround for lint internal crash
abortOnError false
// Ignore obsolete custom lint checks from older fragment library
disable 'ObsoleteLintCustomCheck'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
testOptions {
unitTests.all {
jvmArgs += ['--add-opens', 'java.base/java.lang=ALL-UNNAMED']
}
}
}

repositories {
mavenCentral()
}

dependencies {
compileOnly 'com.google.firebase:firebase-messaging:[10.2.1, )'
api 'com.braze:android-sdk-ui:39.0.0'
testImplementation files('libs/java-json.jar')
}
8 changes: 8 additions & 0 deletions kits/braze/braze-39/consumer-proguard.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# These are the proguard rules specified by the Appboy SDK's documentation

-dontwarn com.amazon.device.messaging.**
-dontwarn bo.app.**
-dontwarn com.braze.ui.**
-dontwarn com.google.android.gms.**
-keep class bo.app.** { *; }
-keep class com.braze.** { *; }
66 changes: 66 additions & 0 deletions kits/braze/braze-39/example/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
*
* Example app build.gradle for using mParticle + Braze + Firebase Cloud Messaging
* Please see the inline comments below.
*
*/


apply plugin: 'com.android.application'

android {
compileSdk 31

defaultConfig {
applicationId "com.mparticle.com.mparticle.kits.braze.example"
minSdk 16
targetSdk 31
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

buildTypes {
release {
minifyEnabled false
}
}
}

repositories {
mavenCentral()
maven { url "https://appboy.github.io/appboy-android-sdk/sdk" } //REQUIRED: Braze isn't available in jCenter or Maven Central - so you need to add their Maven Server
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer the case. The new version of the braze library is available in MavenCentral. We can remove this.

google()
}

buildscript {
repositories {
//REQUIRED: com.google.gms:google-services requires both jCenter and Google's Maven :rollseyes:
mavenCentral()
google()
}
dependencies {
classpath 'com.google.gms:google-services:4.2.0' //REQUIRED for Firebase
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'

// REQUIRED: Add the Braze (formerly Appboy) kit here
// this will also pull in mParticle's Core SDK (com.mparticle:android-core) as a transitive dependency
implementation 'com.mparticle:android-appboy-kit:5.6.5'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example app should be using current kit's dependency. This seems old kit dependency.


// REQUIRED for Firebase
implementation 'com.google.firebase:firebase-messaging:17.3.4'

// Not strictly required but strongly recommended so that mParticle and Braze can query for the Android Advertising ID
implementation 'com.google.android.gms:play-services-ads-identifier:16.0.0'

}

apply plugin: 'com.google.gms.google-services' //REQUIRED for Firebase
43 changes: 43 additions & 0 deletions kits/braze/braze-39/example/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mparticle.kits.braze.example">

<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:name=".ExampleApplication"
android:theme="@style/AppTheme">

<!-- This Braze receiver is necessary to react to pending Intents within push notifications -->
<receiver android:name="com.braze.push.BrazePushReceiver" />

<!-- This mParticle receiver is necessary to register for push notification tokens -->
<receiver

Check warning on line 18 in kits/braze/braze-39/example/src/main/AndroidManifest.xml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Mark this component as exported.

See more on https://sonarcloud.io/project/issues?id=mParticle_mparticle-android-sdk&issues=AZzn_Tcwd6VGRcJGlYbs&open=AZzn_Tcwd6VGRcJGlYbs&pullRequest=677
android:name="com.mparticle.MPReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />

<!-- Use your package name as the category -->
<category android:name="com.mparticle.kits.braze.example" />
</intent-filter>
</receiver>

<!-- This mParticle service is necessary to listen for token-updates -->
<service android:name="com.mparticle.messaging.InstanceIdService" />

<!-- This is the service that takes care of forwarding push registrations, receipts, and opens to Braze -->
<service android:name="com.mparticle.MPService" />

<activity android:name=".MainActivity">

Check warning on line 35 in kits/braze/braze-39/example/src/main/AndroidManifest.xml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Mark this component as exported.

See more on https://sonarcloud.io/project/issues?id=mParticle_mparticle-android-sdk&issues=AZzn_Tcwd6VGRcJGlYbt&open=AZzn_Tcwd6VGRcJGlYbt&pullRequest=677
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.mparticle.kits.braze.example;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeWidth="1"
android:strokeColor="#00000000">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
Loading
Loading