-
-
Save JoeM-RP/271758305aaa5d92a6d435cd85452994 to your computer and use it in GitHub Desktop.
Adobe Analytics Bridge for Expo/iOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <React/RCTBridgeDelegate.h> | |
#import <UIKit/UIKit.h> | |
@interface AdobeBridge : NSObject | |
+ (void)configureAnalytics:(UIApplication *)application; | |
+ (void)analyticsStart; | |
+ (void)analyticsPause; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "AdobeBridge.h" | |
#import "RCTAEPCore.h" | |
@import AEPCore; | |
@import AEPServices; | |
@import AEPSignal; | |
@import AEPLifecycle; | |
@import AEPIdentity; | |
@import AEPUserProfile; | |
@import AEPEdge; | |
@import AEPEdgeIdentity; | |
@import AEPEdgeConsent; | |
@import AEPAssurance; | |
@import AEPOptimize; | |
@implementation AdobeBridge | |
+ (void)configureAnalytics:(UIApplication *)application | |
{ | |
const UIApplicationState appState = application.applicationState; | |
[AEPMobileCore setLogLevel:AEPLogLevelDebug]; | |
[AEPMobileCore configureWithAppId:@"ADOBE_APP_ID_PLACEHOLDER"]; | |
[AEPMobileCore | |
registerExtensions:@[ | |
AEPMobileEdgeIdentity.class, | |
AEPMobileEdge.class, | |
AEPMobileEdgeConsent.class, | |
AEPMobileOptimize.class, | |
AEPMobileLifecycle.class, | |
AEPMobileAssurance.class, | |
AEPMobileIdentity.class | |
] | |
completion:^{ | |
// only start lifecycle if the application is not in the background | |
if (appState != UIApplicationStateBackground) { | |
[AEPMobileCore lifecycleStart:nil]; | |
} | |
}]; | |
} | |
+ (void)analyticsStart | |
{ | |
[AEPMobileCore lifecycleStart:nil]; | |
} | |
+ (void)analyticsPause | |
{ | |
[AEPMobileCore lifecyclePause]; | |
} | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "AppDelegate.h" | |
#import "AdobeBridge.h" | |
#import <React/RCTBundleURLProvider.h> | |
#import <React/RCTLinkingManager.h> | |
#import <React/RCTConvert.h> | |
#import <RNBranch/RNBranch.h> | |
@implementation AppDelegate | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
self.moduleName = @"main"; | |
// You can add your custom initial props in the dictionary below. | |
// They will be passed down to the ViewController used by React Native. | |
self.initialProps = @{}; | |
[super application:application didFinishLaunchingWithOptions:launchOptions]; | |
[AdobeBridge configureAnalytics:application]; | |
// for now using test instance only | |
[RNBranch useTestInstance]; | |
[RNBranch initSessionWithLaunchOptions:launchOptions isReferrable:YES]; | |
NSURL *jsCodeLocation; | |
return YES; | |
} | |
- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge | |
{ | |
// If you'd like to export some custom RCTBridgeModules, add them here! | |
return @[]; | |
} | |
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge | |
{ | |
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"]; | |
} | |
// Linking API | |
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options { | |
[RNBranch application:application openURL:url options:options]; | |
return YES; | |
} | |
// Universal Links | |
- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler { | |
[RNBranch continueUserActivity:userActivity]; | |
return YES; | |
} | |
// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries | |
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken | |
{ | |
return [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; | |
} | |
// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries | |
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error | |
{ | |
return [super application:application didFailToRegisterForRemoteNotificationsWithError:error]; | |
} | |
// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries | |
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler | |
{ | |
return [super application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler]; | |
} | |
- (void) applicationWillEnterForeground:(UIApplication *)application { | |
[AdobeBridge analyticsStart]; | |
} | |
- (void) sceneWillEnterForeground:(UIScene *)scene { | |
[AdobeBridge analyticsStart]; | |
} | |
- (void) applicationDidEnterBackground:(UIApplication *)application { | |
[AdobeBridge analyticsPause]; | |
} | |
- (void) sceneDidEnterBackground:(UIScene *)scene { | |
[AdobeBridge analyticsPause]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment