Created
April 20, 2017 17:49
-
-
Save mlinderman/ccac6e46e4e4c596cca296e89a5e65f2 to your computer and use it in GitHub Desktop.
Swrve initialization
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
if (EPIConfig.swrveAppId > 0 && EPIConfig.swrveApiKey) { | |
SwrveConfig* swrveConfig = [[SwrveConfig alloc] init]; | |
swrveConfig.pushEnabled = [EPIUserServiceManager getEditorialNotificationsEnabled]; | |
swrveConfig.pushNotificationEvents = [[NSSet alloc] initWithArray:@[@"Swrve.push_notification_permission", @"push.permission.accepted"]]; | |
[Swrve sharedInstanceWithAppID:EPIConfig.swrveAppId apiKey:EPIConfig.swrveApiKey config:swrveConfig launchOptions:launchOptions]; | |
} | |
[Swrve sharedInstance].talk.customButtonCallback = ^(NSString* action){ | |
NSURL *url = [NSURL URLWithString:action]; | |
double delayInSeconds = 0.25; | |
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); | |
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ | |
if ([url.scheme isEqualToString:@"swrve"]){ | |
NSArray *pairs = [url.query componentsSeparatedByString:@"&"]; | |
for (NSString *pair in pairs){ | |
NSString *key = [[pair componentsSeparatedByString:@"="] objectAtIndex:0]; | |
NSString *value = [[pair componentsSeparatedByString:@"="] objectAtIndex:1]; | |
if ([key isEqualToString:@"event"]){ | |
[[Swrve sharedInstance] event:value]; | |
} | |
} | |
[[Swrve sharedInstance] sendQueuedEvents]; | |
} else { | |
[[UIApplication sharedApplication] openURL:url]; | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment