Skip to content

Commit

Permalink
Merge pull request #33 from intercom/dev
Browse files Browse the repository at this point in the history
Release 1.0.5
  • Loading branch information
maciejBudzinskiNG authored Sep 3, 2021
2 parents 4a0ed57 + ba70420 commit 2801d3f
Show file tree
Hide file tree
Showing 28 changed files with 15,180 additions and 858 deletions.
5 changes: 4 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2.1
# Default VM config to be used for macOS builds
macos_config: &macos_config
macos:
xcode: 12.3.0
xcode: 12.5.0
shell: /bin/bash --login -eo pipefail

setup_env_file: &setup_env_file
Expand Down Expand Up @@ -109,6 +109,9 @@ jobs:
yarn prepare
# Build and Test android version of module
android-e2e-test:
environment:
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"'
JAVA_OPTS: '-Xms512m -Xmx1024m'
executor:
name: android/android-machine
working_directory: ~/project
Expand Down
47 changes: 7 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Welcome to @intercom/intercom-react-native 👋

[![Version](https://img.shields.io/npm/v/intercom-react-native.svg)](https://www.npmjs.com/package/intercom-react-native)
[![Version](https://img.shields.io/npm/v/@intercom/intercom-react-native.svg)](https://www.npmjs.com/package/@intercom/intercom-react-native)
[![Documentation](https://img.shields.io/badge/documentation-yes-brightgreen.svg)](https://github.com/intercom/intercom-react-native#readme)
[![License: Apache--2.0](https://img.shields.io/badge/License-Apache--2.0-yellow.svg)](https://github.com/intercom/intercom-react-native#readme)
[![CircleCi](https://circleci.com/gh/intercom/intercom-react-native.svg?style=shield)](https://github.com/intercom/intercom-react-native#readme)
Expand Down Expand Up @@ -227,12 +227,13 @@ public class MainNotificationService extends FirebaseMessagingService {
/**
* Handle PushNotification
*/
AppState.addEventListener(
const appStateListener = AppState.addEventListener(
'change',
(nextAppState) =>
nextAppState === 'active' && Intercom.handlePushMessage()
);
return () => AppState.removeEventListener('change', () => true);
return () => AppState.removeEventListener('change', () => true); // <- for RN < 0.65
return () => appStateListener.remove() // <- for RN >= 0.65
}
, [])
```
Expand Down Expand Up @@ -571,38 +572,6 @@ This takes a push registration token to send to Intercom to enable this device t

___

### `Intercom.addOnMessageCountChangeListener(callback)`

Sets a listener that will be notified when the unread conversation count for the registered user changes.

```javascript
useEffect(() => {
/**
* Handle message count changed
*/
const event = Intercom.addOnMessageCountChangeListener(({count}) => {
setCount(count);
});

return () => {
event();
};
}, []);

```

### Options

| Type | Type | Required |
| ------- | -------- | -------- |
| callback| function `({count: number}) => void` |yes |

### Returns

`removeEventListener: () => void`

___

### `Intercom.getUnreadConversationCount()`

Gets the number of unread conversations for a user.
Expand All @@ -621,16 +590,14 @@ Handles the opening of an Intercom push message. This will retrieve the URI from
/**
* Handle PushNotification Open
*/
AppState.addEventListener(
const appStateListener = AppState.addEventListener(
'change',
(nextAppState) =>
nextAppState === 'active' && Intercom.handlePushMessage()
);

return () => {
AppState.removeEventListener('change', () => {
});
};
return () => AppState.removeEventListener('change', () => {}); // <- for RN < 0.65
return () => appStateListener.remove(); // <- for RN >= 0.65
}, []);
```

Expand Down
12 changes: 5 additions & 7 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
if (project == rootProject) {
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
Expand All @@ -23,15 +23,13 @@ def safeExtGet(prop, fallback) {
}

android {
compileSdkVersion safeExtGet('IntercomReactNative_compileSdkVersion', 29)
buildToolsVersion safeExtGet('IntercomReactNative_buildToolsVersion', '29.0.2')
compileSdkVersion safeExtGet('IntercomReactNative_compileSdkVersion', 30)
defaultConfig {
minSdkVersion safeExtGet('IntercomReactNative_minSdkVersion', 21)
targetSdkVersion safeExtGet('IntercomReactNative_targetSdkVersion', 29)
targetSdkVersion safeExtGet('IntercomReactNative_targetSdkVersion', 30)
versionCode 1
versionName "1.0"
buildConfigField 'String', 'INTERCOM_VERSION_NAME', packageVersion

}

buildTypes {
Expand All @@ -49,18 +47,18 @@ android {
}

repositories {
mavenCentral()
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
google()
jcenter()
}

dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'com.google.firebase:firebase-messaging:20.2.+'
implementation 'io.intercom.android:intercom-sdk:10.+'
implementation 'io.intercom.android:intercom-sdk:10.1.+'
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ public IntercomEventEmitter(ReactApplicationContext reactContext) {
super(reactContext);
}

@ReactMethod
public void addListener(String eventName) {
// Keep: Required for RN built in Event Emitter Calls.
}

@ReactMethod
public void removeListeners(Integer count) {
// Keep: Required for RN built in Event Emitter Calls.
}

@ReactMethod
public void startEventListener() {
try {
Expand Down
13 changes: 6 additions & 7 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,9 @@ def jscFlavor = 'org.webkit:android-jsc:+'
def enableHermes = project.ext.react.get("enableHermes", false);

android {
ndkVersion rootProject.ext.ndkVersion
compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
applicationId "com.example.intercomreactnative"
minSdkVersion rootProject.ext.minSdkVersion
Expand Down Expand Up @@ -186,18 +182,21 @@ android {
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// https://developer.android.com/studio/build/configure-apk-splits.html
// Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
}

}
}
}

dependencies {
// implementation("com.squareup.okhttp3:okhttp-urlconnection:4.9.1") <- required for applications that uses RN < 0.65

implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
Expand Down Expand Up @@ -232,7 +231,7 @@ dependencies {
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
from configurations.implementation
into 'libs'
}

Expand Down
7 changes: 6 additions & 1 deletion example/android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
<application
android:usesCleartextTraffic="true"
tools:targetApi="28"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
2 changes: 0 additions & 2 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,5 @@
android:name="com.intercom.reactnative.RNIntercomPushBroadcastReceiver"
tools:replace="android:exported"
android:exported="true" />
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>

</manifest>
2 changes: 1 addition & 1 deletion example/android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:textColor">#000000</item>
</style>
Expand Down
14 changes: 8 additions & 6 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ buildscript {
def isFoss = taskRequests.contains("foss")

ext {
buildToolsVersion = "29.0.2"
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
compileSdkVersion = 30
targetSdkVersion = 30
ndkVersion = "20.1.5948944"
}
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:4.0.1")
classpath("com.android.tools.build:gradle:4.2.1")

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -27,6 +28,7 @@ buildscript {

allprojects {
repositories {
mavenCentral()
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
Expand All @@ -38,7 +40,7 @@ allprojects {
}

google()
jcenter()

maven { url 'https://www.jitpack.io' }
}
}
2 changes: 1 addition & 1 deletion example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@

android.useAndroidX=true
android.enableJetifier=true
FLIPPER_VERSION=0.54.0
FLIPPER_VERSION=0.93.0
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
21 changes: 3 additions & 18 deletions example/android/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand All @@ -54,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
Expand All @@ -64,28 +64,13 @@ echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
Expand Down
6 changes: 3 additions & 3 deletions example/e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ const boot = async () => {
};
driver.addCommand('boot', boot);

const closeOverlay = async () => {
const buttonId = browser.isAndroid ? `~Close` : `~intercom close button`;
const closeOverlay = async (customCloseButtonId?: string) => {
const buttonId = browser.isAndroid ? `~Close` : customCloseButtonId || `~intercom close button`;

const closeButton = await $(buttonId);
await closeButton.waitForDisplayed({ timeout: 22000 });
Expand Down Expand Up @@ -68,7 +68,7 @@ const closeHelpCenterOverlay = async () => {
await closeButton.waitForDisplayed({ timeout: 22000 });
await closeButton.click();
} else {
await closeOverlay();
await closeOverlay('~help center close button');
}
};
browser.addCommand('closeHelpCenterOverlay', closeHelpCenterOverlay);
Expand Down
2 changes: 1 addition & 1 deletion example/e2e/tests/mainIntercom.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('Intercom E2E', () => {

const launcherId = driver.isAndroid
? '~Intercom launcher'
: '~intercom launcher';
: '~launcher';
await (await $(launcherId)).waitForDisplayed({ timeout: 12000 });
await driver.clickWithDelay('~toggle-launcher-visibility', 12000);
});
Expand Down
2 changes: 1 addition & 1 deletion example/e2e/types/wido.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ declare global {
clickWithDelay: (element: string, milis: number) => Promise<void>;
closeHelpCenterOverlay: () => Promise<void>;
closeArticleOverlay: () => Promise<void>;
closeOverlay: () => Promise<void>;
closeOverlay: (customCloseButtonId?: string) => Promise<void>;
closeAlert: () => Promise<void>;
}
}
Expand Down
2 changes: 1 addition & 1 deletion example/e2e/wdio.ios.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exports.config = {
browserName: '',
automationName: 'XCUITest',
platformName: 'iOS',
platformVersion: '14.3',
platformVersion: '14.5',
deviceName: 'iPhone 8',
app: 'build/Build/Products/Release-iphonesimulator/IntercomReactNativeExampleUI.app',
},
Expand Down
Loading

0 comments on commit 2801d3f

Please sign in to comment.