Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added Data Residency support #203

Merged
merged 20 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,7 @@ All notable changes to this project will be documented in this file.
### Feature
- Added session tracking.

## Version - 1.8.0

### Feature
- Added Data Residency Support.
Original file line number Diff line number Diff line change
Expand Up @@ -212,19 +212,11 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-RudderSampleAppObjC/Pods-RudderSampleAppObjC-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework",
"${BUILT_PRODUCTS_DIR}/PromisesObjC/FBLPromises.framework",
"${BUILT_PRODUCTS_DIR}/Protobuf/Protobuf.framework",
"${BUILT_PRODUCTS_DIR}/Rudder-iOS/Rudder.framework",
"${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleUtilities.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBLPromises.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Protobuf.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Rudder.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
//

@import UIKit;
@import UserNotifications;
@import Firebase;
@import FirebaseMessaging;

@interface _AppDelegate : UIResponder <UIApplicationDelegate, UNUserNotificationCenterDelegate, FIRMessagingDelegate>
@interface _AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

Expand Down
137 changes: 1 addition & 136 deletions Examples/RudderSampleAppObjC/RudderSampleAppObjC/_AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[builder withRecordScreenViews:YES];
[builder withEnableBackgroundMode:YES];
[builder withDataPlaneUrl:@"http://localhost:8080"];
[builder withDataResidencyServer:US];
[builder withCustomFactory:[CustomFactory instance]];
[RSClient getInstance:@"1wvsoF3Kx2SczQNlx1dvcqW9ODW" config:[builder build]];

Expand All @@ -56,19 +57,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
];

[[RSClient sharedInstance] alias:@"new_user_id"];
[FIRApp configure];
[FIRMessaging messaging].delegate = self;

[UNUserNotificationCenter currentNotificationCenter].delegate = self;
UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert |
UNAuthorizationOptionSound | UNAuthorizationOptionBadge;
[[UNUserNotificationCenter currentNotificationCenter]
requestAuthorizationWithOptions:authOptions
completionHandler:^(BOOL granted, NSError * _Nullable error) {
// ...
}];

[application registerForRemoteNotifications];
return YES;
}

Expand All @@ -79,127 +67,4 @@ - (NSString*) getIDFA {
- (NSString*) getDeviceToken {
return @"example_device_token";
}

- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

// [START receive_message]
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
// If you are receiving a notification message while your app is in the background,
// this callback will not be fired till the user taps on the notification launching the application.
// TODO: Handle data of notification

// With swizzling disabled you must let Messaging know about the message, for Analytics
// [[FIRMessaging messaging] appDidReceiveMessage:userInfo];

// [START_EXCLUDE]
// Print message ID.
if (userInfo[kGCMMessageIDKey]) {
NSLog(@"Message ID: %@", userInfo[kGCMMessageIDKey]);
}
// [END_EXCLUDE]

// Print full message.
NSLog(@"%@", userInfo);

completionHandler(UIBackgroundFetchResultNewData);
}
// [END receive_message]

// [START ios_10_message_handling]
// Receive displayed notifications for iOS 10 devices.
// Handle incoming notification messages while app is in the foreground.
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
willPresentNotification:(UNNotification *)notification
withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
NSDictionary *userInfo = notification.request.content.userInfo;

// With swizzling disabled you must let Messaging know about the message, for Analytics
// [[FIRMessaging messaging] appDidReceiveMessage:userInfo];

// [START_EXCLUDE]
// Print message ID.
if (userInfo[kGCMMessageIDKey]) {
NSLog(@"Message ID: %@", userInfo[kGCMMessageIDKey]);
}
// [END_EXCLUDE]

// Print full message.
NSLog(@"%@", userInfo);

// Change this to your preferred presentation option
completionHandler(UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionAlert);
}

// Handle notification messages after display notification is tapped by the user.
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void(^)(void))completionHandler {
NSDictionary *userInfo = response.notification.request.content.userInfo;
if (userInfo[kGCMMessageIDKey]) {
NSLog(@"Message ID: %@", userInfo[kGCMMessageIDKey]);
}

// With swizzling disabled you must let Messaging know about the message, for Analytics
// [[FIRMessaging messaging] appDidReceiveMessage:userInfo];

// Print full message.
NSLog(@"%@", userInfo);

completionHandler();
}

// [END ios_10_message_handling]

// [START refresh_token]
- (void)messaging:(FIRMessaging *)messaging didReceiveRegistrationToken:(NSString *)fcmToken {
NSLog(@"FCM registration token: %@", fcmToken);
// Notify about received token.
NSDictionary *dataDict = [NSDictionary dictionaryWithObject:fcmToken forKey:@"token"];
[[NSNotificationCenter defaultCenter] postNotificationName:
@"FCMToken" object:nil userInfo:dataDict];
// TODO: If necessary send token to application server.
// Note: This callback is fired at each app startup and whenever a new token is generated.
}
// [END refresh_token]

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
NSLog(@"Unable to register for remote notifications: %@", error);
}

// This function is added here only for debugging purposes, and can be removed if swizzling is enabled.
// If swizzling is disabled then this function must be implemented so that the APNs device token can be paired to
// the FCM registration token.
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSLog(@"APNs device token retrieved: %@", deviceToken);

// With swizzling disabled you must set the APNs device token here.
// [FIRMessaging messaging].APNSToken = deviceToken;
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -19,64 +19,6 @@ - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

// [[RSClient sharedInstance] identify:@"test_user_id" traits:@{
// @"firstName": @"Test",
// @"lastName": @"Name",
// @"email": @"test_1@gmail.com",
// @"phone": @"+91-986543210",
// @"company": @{
// @"id": @"test_company_id",
// @"name": @"Test Company",
// @"industry": @"Test Industry",
// @"address": @"Test Location"
// }
// }];
//
// [[RSClient sharedInstance] alias:@"some_other_id"];
//
// [[RSClient sharedInstance] track:@"test_event_2" properties:@{
// @"string_key_1": @"string_value",
// @"string_key_2": @"string_value",
// @"string_key_3": @"string_value",
// @"string_key_4": @"string_value",
// @"bool_key": @YES,
// @"num_key": @1.2,
// @"dict_key": @{
// @"c_key_1": @"value_1",
// @"c_key_2": @"value_2"
// }
// }];

// RSOption *options = [[RSOption alloc] init];
// [options putExternalId:@"test" withId:@"test"];
// [[RSClient sharedInstance] screen:@"ViewController"];
// [[RSClient sharedInstance] screen:@"Main screen name" properties:@{@"prop_key" : @"prop_value"}];
// [[RSClient sharedInstance] screen:@"test screen" properties:@{@"prop_key" : @"prop_value"} options:options];

// dispatch_async(dispatch_get_main_queue(), ^{
// NSMutableDictionary *traits = [[NSMutableDictionary alloc] initWithDictionary:@{
// @"firstName": @"Test",
// @"lastName": @"Name",
// @"email": @"test_1@gmail.com",
// @"phone": @"+91-986543210",
// @"company": @{
// @"id": @"test_company_id",
// @"name": @"Test Company",
// @"industry": @"Test Industry",
// @"address": @"Test Location"
// },
// @"user_id": [NSNull null]
// }];
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
// [[RSClient sharedInstance] identify:@"test_user_id" traits:@{}];
// });

// [traits removeAllObjects];
// [traits setValue:@"Kolkata" forKey:@"address"];
// });


}

- (void)didReceiveMemoryWarning
Expand Down
2 changes: 0 additions & 2 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ target 'RudderSampleAppObjC' do
project 'Examples/RudderSampleAppObjC/RudderSampleAppObjC.xcodeproj'
platform :ios, '9.0'
shared_pods
pod 'Firebase/Analytics'
pod 'Firebase/Messaging'
end

target 'RudderSampleAppSwift' do
Expand Down