Skip to content

Instantly share code, notes, and snippets.

@mustafa
Created June 2, 2013 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mustafa/d3c8c6938db45af0667f to your computer and use it in GitHub Desktop.
Save mustafa/d3c8c6938db45af0667f to your computer and use it in GitHub Desktop.
NSMutableDictionary* appBridgeData = [NSMutableDictionary dictionary];
ENSearchRequest* request = [[ENSearchRequest alloc] init];
[request setQueryString:@"notebook:\"Food\""];
NSData *requestData = [NSKeyedArchiver archivedDataWithRootObject:request];
[appBridgeData setObject:requestData forKey:kEN_ApplicationBridge_RequestDataKey];
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
if (infoDictionary != nil) {
NSString *appIdentifier = [infoDictionary objectForKey:(NSString *)kCFBundleIdentifierKey];
if (appIdentifier != nil) {
[appBridgeData setObject:appIdentifier forKey:kEN_ApplicationBridge_CallerAppIdentifierKey];
}
NSString *appName = [infoDictionary objectForKey:(NSString *)kCFBundleNameKey];
if (appName != nil) {
[appBridgeData setObject:appName forKey:kEN_ApplicationBridge_CallerAppNameKey];
}
}
[appBridgeData setObject:[NSNumber numberWithUnsignedInt:kEN_ApplicationBridge_DataVersion] forKey:kEN_ApplicationBridge_DataVersionKey];
[appBridgeData setObject:[request requestIdentifier] forKey:kEN_ApplicationBridge_RequestIdentifierKey];
[appBridgeData setObject:[[EvernoteSession sharedSession] consumerKey] forKey:kEN_ApplicationBridge_ConsumerKey];
NSString* pasteboardName = [NSString stringWithFormat:@"com.evernote.bridge.%@",[[EvernoteSession sharedSession] consumerKey]];
UIPasteboard *pasteboard = [UIPasteboard pasteboardWithName:pasteboardName create:YES];
[pasteboard setPersistent:YES];
[pasteboard setData:[NSKeyedArchiver archivedDataWithRootObject:appBridgeData] forPasteboardType:@"$EvernoteApplicationBridgeData$"];
NSString* openURL = [NSString stringWithFormat:@"en://app-bridge/consumerKey/%@/pasteBoardName/%@",[[EvernoteSession sharedSession] consumerKey],pasteboardName];
BOOL success = [[UIApplication sharedApplication] openURL:[NSURL URLWithString:openURL]];
if(success) {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment