Created
April 12, 2017 07:44
-
-
Save NSExceptional/9bbf6e892e22dcd8ed39e8c035746bb4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
static NSMutableURLRequest * SKMakeRequest(NSDictionary *message) { | |
SKIPCRequest *query = message[kQueryKey]; | |
return [SKIPCQueryBuilder endpoint:query]; | |
} | |
static void SKIPCSpringboardInit() { | |
// Allow passing messages to Snapchat from other apps | |
[OBJCIPC registerIncomingMessageFromAppHandlerForMessageName:kQueryName handler:^NSDictionary *(NSDictionary *query) { | |
// Delegate query to Snapchat, propagate result to caller | |
NSDictionary *object = [OBJCIPC sendMessageToAppWithIdentifier:kSnapchatBundleID messageName:kQueryName dictionary:query]; | |
return @{kResponseKey: [SKIPCResponse response:object error:nil]}; | |
}]; | |
} | |
static void SKIPCSnapchatInit() { | |
// Register Snapchat for query messages from Springboard | |
[OBJCIPC registerIncomingMessageFromSpringBoardHandlerForMessageName:kQueryName handler:^NSDictionary *(NSDictionary *query) { | |
NSLog(@"***\nReceived message: %@", query); | |
return @{kURLRequestKey: SKMakeRequest(query)}; | |
}]; | |
} | |
%ctor { | |
if ([OBJCIPC isSpringBoard]) { | |
SKIPCSpringboardInit(); | |
} else { | |
SKIPCSnapchatInit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment