secret
Created

  • Download Gist
gistfile1.m
Objective-C
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
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) {
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.