Skip to content

Commit

Permalink
feat: added Data Residency support (#203)
Browse files Browse the repository at this point in the history
* Added Support for DataResidency feature

* Bumped the version to 1.8.0

* Added Unit TestCases for the Data-Residency Feature

* Refactored DataResidencyServer to RSDataResidencyServer

* Minor improvements in the constructor of RSConfig

* Addressed comments for parsing data residency URL's from sourceConfig

* Update CHANGELOG.md

* chore: Added the support for parsing Multiple Data Plane URL's for each Data Residency Region

* fix: Fixed Issues related to returning a nil type from functions

* fix: Checking if the residencyURL is nil before using it

* made the enum swift compatible

* test: updated enum access in unit tests

* fix: made changes as per sonarcloud bug

---------

Co-authored-by: Desu Sai Venkat <desusaivenkat@Desus-MacBook-Pro.local>
Co-authored-by: Pallab Maiti <mynamepallabmaiti@gmail.com>
Co-authored-by: Pallab Maiti <pallab@rudderstack.com>
Co-authored-by: Abhishek Pandey <abhishekpandey10196@gmail.com>
  • Loading branch information
5 people committed Feb 1, 2023
1 parent 180c1b2 commit 3b2b933
Show file tree
Hide file tree
Showing 22 changed files with 568 additions and 327 deletions.
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
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
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
58 changes: 0 additions & 58 deletions Examples/RudderSampleAppObjC/RudderSampleAppObjC/_ViewController.m
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
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
117 changes: 3 additions & 114 deletions Podfile.lock
@@ -1,127 +1,16 @@
PODS:
- Firebase/Analytics (6.34.0):
- Firebase/Core
- Firebase/Core (6.34.0):
- Firebase/CoreOnly
- FirebaseAnalytics (= 6.9.0)
- Firebase/CoreOnly (6.34.0):
- FirebaseCore (= 6.10.4)
- Firebase/Messaging (6.34.0):
- Firebase/CoreOnly
- FirebaseMessaging (~> 4.7.1)
- FirebaseAnalytics (6.9.0):
- FirebaseCore (~> 6.10)
- FirebaseInstallations (~> 1.7)
- GoogleAppMeasurement (= 6.9.0)
- GoogleUtilities/AppDelegateSwizzler (~> 6.7)
- GoogleUtilities/MethodSwizzler (~> 6.7)
- GoogleUtilities/Network (~> 6.7)
- "GoogleUtilities/NSData+zlib (~> 6.7)"
- nanopb (~> 1.30906.0)
- FirebaseCore (6.10.4):
- FirebaseCoreDiagnostics (~> 1.6)
- GoogleUtilities/Environment (~> 6.7)
- GoogleUtilities/Logger (~> 6.7)
- FirebaseCoreDiagnostics (1.7.0):
- GoogleDataTransport (~> 7.4)
- GoogleUtilities/Environment (~> 6.7)
- GoogleUtilities/Logger (~> 6.7)
- nanopb (~> 1.30906.0)
- FirebaseInstallations (1.7.0):
- FirebaseCore (~> 6.10)
- GoogleUtilities/Environment (~> 6.7)
- GoogleUtilities/UserDefaults (~> 6.7)
- PromisesObjC (~> 1.2)
- FirebaseInstanceID (4.8.0):
- FirebaseCore (~> 6.10)
- FirebaseInstallations (~> 1.6)
- GoogleUtilities/Environment (~> 6.7)
- GoogleUtilities/UserDefaults (~> 6.7)
- FirebaseMessaging (4.7.1):
- FirebaseCore (~> 6.10)
- FirebaseInstanceID (~> 4.7)
- GoogleUtilities/AppDelegateSwizzler (~> 6.7)
- GoogleUtilities/Environment (~> 6.7)
- GoogleUtilities/Reachability (~> 6.7)
- GoogleUtilities/UserDefaults (~> 6.7)
- Protobuf (>= 3.9.2, ~> 3.9)
- GoogleAppMeasurement (6.9.0):
- GoogleUtilities/AppDelegateSwizzler (~> 6.7)
- GoogleUtilities/MethodSwizzler (~> 6.7)
- GoogleUtilities/Network (~> 6.7)
- "GoogleUtilities/NSData+zlib (~> 6.7)"
- nanopb (~> 1.30906.0)
- GoogleDataTransport (7.5.1):
- nanopb (~> 1.30906.0)
- GoogleUtilities/AppDelegateSwizzler (6.7.2):
- GoogleUtilities/Environment
- GoogleUtilities/Logger
- GoogleUtilities/Network
- GoogleUtilities/Environment (6.7.2):
- PromisesObjC (~> 1.2)
- GoogleUtilities/Logger (6.7.2):
- GoogleUtilities/Environment
- GoogleUtilities/MethodSwizzler (6.7.2):
- GoogleUtilities/Logger
- GoogleUtilities/Network (6.7.2):
- GoogleUtilities/Logger
- "GoogleUtilities/NSData+zlib"
- GoogleUtilities/Reachability
- "GoogleUtilities/NSData+zlib (6.7.2)"
- GoogleUtilities/Reachability (6.7.2):
- GoogleUtilities/Logger
- GoogleUtilities/UserDefaults (6.7.2):
- GoogleUtilities/Logger
- nanopb (1.30906.0):
- nanopb/decode (= 1.30906.0)
- nanopb/encode (= 1.30906.0)
- nanopb/decode (1.30906.0)
- nanopb/encode (1.30906.0)
- PromisesObjC (1.2.12)
- Protobuf (3.21.5)
- Rudder (1.7.1)
- Rudder (1.7.2)

DEPENDENCIES:
- Firebase/Analytics
- Firebase/Messaging
- Rudder (from `.`)

SPEC REPOS:
trunk:
- Firebase
- FirebaseAnalytics
- FirebaseCore
- FirebaseCoreDiagnostics
- FirebaseInstallations
- FirebaseInstanceID
- FirebaseMessaging
- GoogleAppMeasurement
- GoogleDataTransport
- GoogleUtilities
- nanopb
- PromisesObjC
- Protobuf

EXTERNAL SOURCES:
Rudder:
:path: "."

SPEC CHECKSUMS:
Firebase: c23a36d9e4cdf7877dfcba8dd0c58add66358999
FirebaseAnalytics: 3bb096873ee0d7fa4b6c70f5e9166b6da413cc7f
FirebaseCore: d3a978a3cfa3240bf7e4ba7d137fdf5b22b628ec
FirebaseCoreDiagnostics: 770ac5958e1372ce67959ae4b4f31d8e127c3ac1
FirebaseInstallations: 466c7b4d1f58fe16707693091da253726a731ed2
FirebaseInstanceID: bd3ffc24367f901a43c063b36c640b345a4a5dd1
FirebaseMessaging: 5eca4ef173de76253352511aafef774caa1cba2a
GoogleAppMeasurement: a6a3a066369828db64eda428cb2856dc1cdc7c4e
GoogleDataTransport: f56af7caa4ed338dc8e138a5d7c5973e66440833
GoogleUtilities: 7f2f5a07f888cdb145101d6042bc4422f57e70b3
nanopb: 59317e09cf1f1a0af72f12af412d54edf52603fc
PromisesObjC: 3113f7f76903778cf4a0586bd1ab89329a0b7b97
Protobuf: 7504b04fffcf6662ad629694db8231f5e744327f
Rudder: 61568212171ddc2efe7785d0a6a0de589d181370
Rudder: 473a45c60ca589c1f9bce568f4837c46a1b15de4

PODFILE CHECKSUM: 33b0e9f1b94a028aa8a3b4aecf718a44c9b6265e
PODFILE CHECKSUM: b22a79db44ea2c78e3500063ff2c7312ef613413

COCOAPODS: 1.11.3

0 comments on commit 3b2b933

Please sign in to comment.