-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReferral Functionality
More file actions
44 lines (37 loc) · 1.66 KB
/
Referral Functionality
File metadata and controls
44 lines (37 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"ABC://"]]) {
NSDictionary *dictCustom = [[NSDictionary alloc]init];
NSLog(@"url recieved: %@", url);
NSLog(@"query string: %@", [url query]);
NSLog(@"host: %@", [url host]);
NSLog(@"url path: %@", [url path]);
dictCustom = [self parseQueryString:[url query]];
NSLog(@"query dict: %@", dictCustom);
NSUserDefaults *defUser = [NSUserDefaults standardUserDefaults];
NSMutableDictionary* registerDict = [defUser valueForKey:kReferralKey];
if(registerDict.count == 0) {
[defUser removeObjectForKey:kReferralKey ];
[defUser setObject:[dictCustom mutableCopy] forKey:kReferralKey];
}
}
return NO;
}
- (NSDictionary *)parseQueryString:(NSString *)query {
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:6] ;
NSArray *pairs = [query componentsSeparatedByString:@"&"];
for (NSString *pair in pairs)
{
NSArray *elements = [pair componentsSeparatedByString:@"="];
NSString *key = [[elements objectAtIndex:0] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *val = [[elements objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[dict setObject:val forKey:key];
}
return dict;
}
NOTE: go to -> info -> URL types
add
identifire abc.abc.com
URL schemes ABC
Role -> viewer