Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/bundler/sandboxes/NotificationsSa…
Browse files Browse the repository at this point in the history
…ndbox/rexml-3.2.8
  • Loading branch information
bscanlan authored Jan 8, 2025
2 parents 960733b + cde7578 commit 9317632
Show file tree
Hide file tree
Showing 48 changed files with 71,621 additions and 32,315 deletions.
5 changes: 3 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ version: 2.1
# Default VM config to be used for macOS builds
macos_config: &macos_config
macos:
xcode: 14.0.0
resource_class: macos.x86.medium.gen2
xcode: 15.3.0
resource_class: macos.m1.large.gen1
shell: /bin/bash --login -eo pipefail

setup_env_file: &setup_env_file
Expand Down Expand Up @@ -53,6 +53,7 @@ jobs:
- run:
name: Install dependencies
command: |
corepack enable
yarn install --cwd example
yarn install --cwd example/e2e
yarn install
Expand Down
106 changes: 94 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ ___
- [Push Notifications](#ios-push-notifications)
- [Push notification deep links support](#ios-push-notification-deep-links-support)
- [Expo](#expo)
- [Limitations](#limitations)
- [Push Notifications](#expo-push-notifications)
- [Push notification deep links support](#expo-push-notification-deep-links-support)
- [Android](#android-deep-link)
- [iOS](#ios-deep-link)
- [Common methods](#methods)
- [Types](#types)
- [Usage](#usage)
Expand Down Expand Up @@ -278,7 +281,16 @@ public class MainNotificationService extends FirebaseMessagingService {

```

See the [example app](https://github.com/intercom/intercom-react-native/blob/main/example/src/App.tsx) for an example of how to handle deep linking in your app.
Add the following in your `MainActivity`

```kotlin
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
setIntent(intent)
}
```

See the [example app](https://github.com/intercom/intercom-react-native/blob/main/sandboxes/NotificationsSandbox/App.tsx) for an example of how to handle deep linking in your app.

### IOS

Expand Down Expand Up @@ -473,7 +485,7 @@ The plugin provides props for extra customization. Every time you change the pro
}
```

#### Push notifications
#### Expo: Push notifications

Add the following configurations into your `app.json` or `app.config.js`:

Expand Down Expand Up @@ -512,10 +524,85 @@ e.g. [react-native-permissions](https://github.com/zoontek/react-native-permissi

Next, rebuild your app as described in the ["Adding custom native code"](https://docs.expo.io/workflow/customizing/) guide.

#### Expo: Push notification deep links support

> **Note**: You can read more on Expo [documentation](https://docs.expo.dev/guides/deep-linking)

#### Android: Deep Link

```json
{
"expo": {
"android": {
"intentFilters": [
{
"action": "VIEW",
"data": [
{
"host": "Your app scheme(app)"
}
],
"category": ["BROWSABLE", "DEFAULT"]
}
]
}
}
}
```

#### Android: App Links

```json
{
"expo": {
"android": {
"intentFilters": [
{
"action": "VIEW",
"autoVerify": true,
"data": [
{
"scheme": "https",
"host": "Your app url(www.app.com)",
"pathPrefix": "Your url prefix e.g. /settings)"
}
],
"category": ["BROWSABLE", "DEFAULT"]
}
]
}
}
}
```

#### iOS: Deep Link

#### Limitations
```json
{
"expo": {
"ios": {
"infoPlist": {
"LSApplicationQueriesSchemes": ["Your app scheme(app)"]
}
}
}
}
```

#### iOS: Universal Link

```json
{
"expo": {
"ios": {
"infoPlist": {
"IntercomUniversalLinkDomains": ["Your app url(www.app.com)"]
}
}
}
}
```

- **No deep links support**: Deep Linking currently is not supported by this config plugin extension. This will be added in the future.


## Methods
Expand Down Expand Up @@ -766,7 +853,7 @@ Fetch a list of all Collections.
___
### `Intercom.fetchHelpCenterCollection(collectionId)`

Get a list of sections/articles for a collection.
Get a list of subcollections/articles for a collection.

### Options

Expand Down Expand Up @@ -935,11 +1022,6 @@ type HelpCenterArticle = {
title: string;
};

type HelpCenterSection = {
name: string;
articles: HelpCenterArticle;
};

type HelpCenterCollectionItem = {
id: string;
title: string;
Expand All @@ -951,7 +1033,7 @@ type HelpCenterCollectionContent = {
name: string;
summary: string;
articles: HelpCenterArticle[];
sections: HelpCenterSection[];
collections: HelpCenterCollectionItem[];
};

type HelpCenterArticleSearchResult = {
Expand Down
100 changes: 50 additions & 50 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
def packageJsonFile = file('../package.json')
def packageJson = new groovy.json.JsonSlurper().parseText(packageJsonFile.text)
def packageVersion = '"' + packageJson.version + '"'
def packageJsonFile = file('../package.json')
def packageJson = new groovy.json.JsonSlurper().parseText(packageJsonFile.text)
def packageVersion = '"' + packageJson.version + '"'


buildscript {
if (project == rootProject) {
repositories {
google()
mavenCentral()
}
ext {
buildToolsVersion = "34.0.0"
minSdkVersion = 21
compileSdkVersion = 34
targetSdkVersion = 34
ndkVersion = "25.1.8937393"
kotlinVersion = "1.8.0"
}
if (project == rootProject) {
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
}
dependencies {
classpath("com.android.tools.build:gradle")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
}
}
}

apply plugin: 'com.android.library'

def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

android {
// Compatibility for AGP v. <4.2/Gradle 8
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger()
if (agpVersion >= 7) {
namespace 'com.intercom.reactnative'
}
namespace 'com.intercom.reactnative'
compileSdk rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

compileSdkVersion safeExtGet('IntercomReactNative_compileSdkVersion', 34)
defaultConfig {
minSdkVersion safeExtGet('IntercomReactNative_minSdkVersion', 21)
targetSdkVersion safeExtGet('IntercomReactNative_targetSdkVersion', 34)
versionCode 1
versionName "1.0"
buildConfigField 'String', 'INTERCOM_VERSION_NAME', packageVersion
}
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
buildConfigField 'String', 'INTERCOM_VERSION_NAME', packageVersion
}

buildTypes {
release {
minifyEnabled false
}
}
lintOptions {
disable 'GradleCompatible'
}

if (agpVersion < 8) {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
}
}
lintOptions {
disable 'GradleCompatible'
}
}

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()
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()
}

dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.google.firebase:firebase-messaging:${safeExtGet('firebaseMessagingVersion', '20.2.+')}"
implementation 'io.intercom.android:intercom-sdk:15.8.+'
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.google.firebase:firebase-messaging:${safeExtGet('firebaseMessagingVersion', '20.2.+')}"
implementation 'io.intercom.android:intercom-sdk:15.11.+'
}
2 changes: 1 addition & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest package="com.intercom.reactnative" xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import io.intercom.android.sdk.helpcenter.collections.HelpCenterCollection;
import io.intercom.android.sdk.helpcenter.sections.HelpCenterArticle;
import io.intercom.android.sdk.helpcenter.sections.HelpCenterCollectionContent;
import io.intercom.android.sdk.helpcenter.sections.HelpCenterSection;

public class IntercomHelpCenterHelpers {

Expand Down Expand Up @@ -59,38 +58,13 @@ public static WritableMap parseHelpCenterCollectionsContentToReadableMap(HelpCen
WritableArray articles = parseArticlesToReadableArray(helpCenterCollectionContent.getHelpCenterArticles());
helpCenterCollection.putArray("articles", articles);

WritableArray sections = parseHelpCenterSectionsToReadableArray(helpCenterCollectionContent.getHelpCenterSections());
helpCenterCollection.putArray("sections", sections);
WritableArray collections = parseHelpCenterCollectionsToReadableArray(helpCenterCollectionContent.getSubCollections());
helpCenterCollection.putArray("collections", collections);


return helpCenterCollection;
}

public static WritableMap parseHelpCenterSectionToReadableMap(HelpCenterSection helpCenterSection) {
WritableMap section = Arguments.createMap();
section.putString("title", helpCenterSection.getTitle());


WritableArray articles = parseArticlesToReadableArray(helpCenterSection.getHelpCenterArticles());
section.putArray("articles", articles);


return section;
}

public static WritableArray parseHelpCenterSectionsToReadableArray(List<HelpCenterSection> helpCenterSectionList) {
WritableArray sections = Arguments.createArray();

HelpCenterSection[] sectionsArray = new HelpCenterSection[helpCenterSectionList.size()];
sectionsArray = helpCenterSectionList.toArray(sectionsArray);
;

for (HelpCenterSection section : sectionsArray) {
sections.pushMap(parseHelpCenterSectionToReadableMap(section));
}
return sections;
}

public static WritableArray parseHelpCenterCollectionsToReadableArray(List<HelpCenterCollection> helpCenterCollections) {
HelpCenterCollection[] collectionsArray = new HelpCenterCollection[helpCenterCollections.size()];
collectionsArray = helpCenterCollections.toArray(collectionsArray);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReadableMapKeySetIterator;
import com.facebook.react.bridge.ReadableType;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;

import java.util.ArrayList;
import java.util.Date;
Expand All @@ -16,6 +18,7 @@
import io.intercom.android.sdk.Company;
import io.intercom.android.sdk.Intercom;
import io.intercom.android.sdk.UserAttributes;
import io.intercom.android.sdk.identity.Registration;

public class IntercomHelpers {

Expand Down Expand Up @@ -241,4 +244,15 @@ public static String getValueAsStringForKey(ReadableMap map, String key) {
}
return value;
}

public static WritableMap deconstructRegistration(Registration registration) {
WritableMap registrationMap = Arguments.createMap();
if (registration.getEmail() != null) {
registrationMap.putString("email", registration.getEmail());
}
if (registration.getUserId() != null) {
registrationMap.putString("userId", registration.getUserId());
}
return registrationMap;
}
}
Loading

0 comments on commit 9317632

Please sign in to comment.