Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
783a069
feat(ios): bridged ios sdk methods
May 26, 2021
625fe98
feat(ios): ios push notifications and deep lining support
May 27, 2021
7545dad
fix(ios): removed typu in app delegate
May 27, 2021
2db8f0f
docs(ios): added setup guide for ios
May 27, 2021
7d487ff
fix(example): added missing permission to ios example app
May 27, 2021
bf4bb59
fix(android): module name was unified with ios
May 28, 2021
310ed44
fix(ios): added intercom module to compile sources
May 28, 2021
2ef9617
feat(ios): added intercom ios sdk source for manual linking
May 28, 2021
2512a62
feat(js): added named default export for intercom module
May 28, 2021
d611b55
docs(ios): added ios manual linking information to readme
May 28, 2021
d1e290a
docs(ios): removed header syntax
May 28, 2021
bddd05e
docs(ios): added link to usage
May 28, 2021
21a8759
docs(troubleshooting): added troubleshooting section
May 28, 2021
419cb5f
fix(ios): fixed requiresMainQueueSetup warning message
May 31, 2021
8a58403
fix(ios): changed algorithm for generating data from token string
May 31, 2021
1f2900f
docs(events): added information about addEventListener
Jun 1, 2021
77cb947
feat(example): updated example app
Jun 1, 2021
4eade16
docs(methods): updated description of set user hash method
Jun 1, 2021
ee4f5eb
fix(types): changed handle push message return type
Jun 2, 2021
a26ec84
docs(methods): fixed readme typo
pi0trpietruszewski Jun 2, 2021
2363c61
docs(linking): moved linking information to top of platform section
Jun 2, 2021
91dc7ba
Merge remote-tracking branch 'origin/ios-integration' into ios-integr…
Jun 2, 2021
f4eac2a
docs(linking): linked to cocoapods install command section
Jun 2, 2021
4722d0f
fix(listeners): fixed event listeners handling
Jun 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
469 changes: 279 additions & 190 deletions README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

@ReactModule(name = IntercomModule.NAME)
public class IntercomModule extends ReactContextBaseJavaModule {
public static final String NAME = "Intercom";
public static final String NAME = "IntercomModule";

private static final IntercomPushClient intercomPushClient = new IntercomPushClient();

Expand Down
18 changes: 18 additions & 0 deletions docs/IOS-MANUAL-LINKING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Intercom IOS Manual linking

## More info about [Manual Linking](https://reactnative.dev/docs/linking-libraries-ios)

- In project root make `react-native link` command
- In Xcode open `YourApp.xcworkspace`, if there is no file with extension `xcworkspace` open `YourApp.xcodeproj`
- In file browser open `./node_modules/intercom-react-native/ios`
- From file browser drag `Intercom.xcframework` and drop in Xcode window under YourProject name
![Xcode linking](xcode-linking.png)

___

- In popup mark `Copy items if needed`
![Xcode popup](xcode-popup.png)

___

- 🎉 Done 🎉 Intercom SDK is linked
Binary file added docs/xcode-linking.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/xcode-popup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 35 additions & 1 deletion example/ios/IntercomReactNativeExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
2D02E47B1E0B4A5D006451C7 /* IntercomReactNativeExample-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "IntercomReactNativeExample-tvOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
2D02E4901E0B4A5D006451C7 /* IntercomReactNativeExample-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "IntercomReactNativeExample-tvOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
47F7ED3B7971BE374F7B8635 /* Pods-IntercomReactNativeExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-IntercomReactNativeExample.debug.xcconfig"; path = "Target Support Files/Pods-IntercomReactNativeExample/Pods-IntercomReactNativeExample.debug.xcconfig"; sourceTree = "<group>"; };
7D4EACBB265F79DC004A6F30 /* IntercomReactNativeExample.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = IntercomReactNativeExample.entitlements; path = IntercomReactNativeExample/IntercomReactNativeExample.entitlements; sourceTree = "<group>"; };
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = IntercomReactNativeExample/LaunchScreen.storyboard; sourceTree = "<group>"; };
CA3E69C5B9553B26FBA2DF04 /* libPods-IntercomReactNativeExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-IntercomReactNativeExample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
E00ACF0FDA8BF921659E2F9A /* Pods-IntercomReactNativeExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-IntercomReactNativeExample.release.xcconfig"; path = "Target Support Files/Pods-IntercomReactNativeExample/Pods-IntercomReactNativeExample.release.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -110,6 +111,7 @@
13B07FAE1A68108700A75B9A /* IntercomReactNativeExample */ = {
isa = PBXGroup;
children = (
7D4EACBB265F79DC004A6F30 /* IntercomReactNativeExample.entitlements */,
008F07F21AC5B25A0029DE68 /* main.jsbundle */,
13B07FAF1A68108700A75B9A /* AppDelegate.h */,
13B07FB01A68108700A75B9A /* AppDelegate.m */,
Expand Down Expand Up @@ -137,7 +139,6 @@
47F7ED3B7971BE374F7B8635 /* Pods-IntercomReactNativeExample.debug.xcconfig */,
E00ACF0FDA8BF921659E2F9A /* Pods-IntercomReactNativeExample.release.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
Expand Down Expand Up @@ -206,6 +207,7 @@
13B07F8E1A680F5B00A75B9A /* Resources */,
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
C1D60D28B925C94BD88E79D7 /* [CP] Copy Pods Resources */,
D406ECB8CE77342EE06D0FE1 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -267,6 +269,7 @@
};
13B07F861A680F5B00A75B9A = {
LastSwiftMigration = 1120;
ProvisioningStyle = Manual;
};
2D02E47A1E0B4A5D006451C7 = {
CreatedOnToolsVersion = 8.2.1;
Expand Down Expand Up @@ -403,6 +406,26 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-IntercomReactNativeExample/Pods-IntercomReactNativeExample-resources.sh\"\n";
showEnvVarsInLog = 0;
};
D406ECB8CE77342EE06D0FE1 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-IntercomReactNativeExample/Pods-IntercomReactNativeExample-frameworks.sh",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/Intercom/Intercom.framework/Intercom",
"${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL/OpenSSL.framework/OpenSSL",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Intercom.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OpenSSL.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-IntercomReactNativeExample/Pods-IntercomReactNativeExample-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
FD10A7F022414F080027D42C /* Start Packager */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -498,6 +521,7 @@
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
DEVELOPMENT_TEAM = "";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
Expand All @@ -521,6 +545,7 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
COPY_PHASE_STRIP = NO;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = IntercomReactNativeExampleTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
Expand All @@ -541,6 +566,9 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = IntercomReactNativeExample/IntercomReactNativeExample.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = IntercomReactNativeExample/Info.plist;
Expand All @@ -552,6 +580,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.intercomreactnative;
PRODUCT_NAME = IntercomReactNativeExample;
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -564,7 +593,11 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = IntercomReactNativeExample/IntercomReactNativeExample.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = IntercomReactNativeExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
Expand All @@ -574,6 +607,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.intercomreactnative;
PRODUCT_NAME = IntercomReactNativeExample;
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "83CBBA2D1A601D0E00E9B192"
BuildableName = "libReact.a"
BlueprintName = "React"
ReferencedContainer = "container:../node_modules/react-native/React/React.xcodeproj">
BlueprintIdentifier = "13B07F861A680F5B00A75B9A"
BuildableName = "IntercomReactNativeExample.app"
BlueprintName = "IntercomReactNativeExample"
ReferencedContainer = "container:IntercomReactNativeExample.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
Expand Down Expand Up @@ -71,6 +71,10 @@
ReferencedContainer = "container:IntercomReactNativeExample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<LocationScenarioReference
identifier = "com.apple.dt.IDEFoundation.CurrentLocationScenarioIdentifier"
referenceType = "1">
</LocationScenarioReference>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
89 changes: 61 additions & 28 deletions example/ios/IntercomReactNativeExample/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,53 +10,86 @@
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <IntercomModule.h>
#import <UserNotifications/UserNotifications.h>
#import <React/RCTLinkingManager.h>

#ifdef FB_SONARKIT_ENABLED

#import <FlipperKit/FlipperClient.h>
#import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
#import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
#import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>

static void InitializeFlipper(UIApplication *application) {
FlipperClient *client = [FlipperClient sharedClient];
SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
[client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]];
[client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
[client addPlugin:[FlipperKitReactPlugin new]];
[client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
[client start];
FlipperClient *client = [FlipperClient sharedClient];
SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
[client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]];
[client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
[client addPlugin:[FlipperKitReactPlugin new]];
[client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
[client start];
}

#endif

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#ifdef FB_SONARKIT_ENABLED
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
#ifdef FB_SONARKIT_ENABLED
InitializeFlipper(application);
#endif
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"IntercomReactNativeExample"
initialProperties:nil];

rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
return YES;
#endif
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"IntercomReactNativeExample"
initialProperties:nil];

rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;

[IntercomModule initialize:@"APP KEY" withAppId:@"APP ID"];

[self.window makeKeyAndVisible];

UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
[center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert + UNAuthorizationOptionSound)
completionHandler:^(BOOL granted, NSError *_Nullable error) {
}];
[[UIApplication sharedApplication] registerForRemoteNotifications];


return YES;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[IntercomModule setDeviceToken:deviceToken];
}

- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
return [RCTLinkingManager application:application openURL:url options:options];
}

- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity
restorationHandler:(nonnull void (^)(NSArray<id <UIUserActivityRestoring>> *_Nullable))restorationHandler {
return [RCTLinkingManager application:application
continueUserActivity:userActivity
restorationHandler:restorationHandler];
}


- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

Expand Down
19 changes: 19 additions & 0 deletions example/ios/IntercomReactNativeExample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,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>NSPhotoLibraryUsageDescription</key>
<string>Send photos to support center</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
Expand All @@ -20,6 +22,19 @@
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>intercom</string>
<key>CFBundleURLSchemes</key>
<array>
<string>intercom</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
Expand All @@ -39,6 +54,10 @@
</dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?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>aps-environment</key>
<string>development</string>
</dict>
</plist>
Loading