Created
June 14, 2015 06:24
-
-
Save benbahrenburg/f64538abc1f42cec7752 to your computer and use it in GitHub Desktop.
Titanium iOS 9 support for hand off
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
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity | |
restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler | |
{ | |
NSMutableDictionary *dict = [NSMutableDictionary | |
dictionaryWithObjectsAndKeys:[userActivity activityType],@"activityType", | |
nil]; | |
if([userActivity title] !=nil){ | |
[dict setObject:[userActivity title] forKey:@"title"]; | |
} | |
if([userActivity webpageURL] !=nil){ | |
[dict setObject:[[userActivity webpageURL] absoluteString] forKey:@"webpageURL"]; | |
} | |
if([userActivity userInfo] !=nil){ | |
[dict setObject:[userActivity userInfo] forKey:@"userInfo"]; | |
} | |
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_9_0 | |
if([TiUtils isIOS9OrGreater]) | |
{ | |
#pragma clang diagnostic push | |
#pragma clang diagnostic ignored "-Wundeclared-selector" | |
if([userActivity respondsToSelector:@selector(contentType)]){ | |
[dict setObject:[userActivity contentType] forKey:@"contentType"]; | |
} | |
if([userActivity respondsToSelector:@selector(contentUserAction)]){ | |
[dict setObject:[userActivity contentUserAction] forKey:@"contentUserAction"]; | |
} | |
if([userActivity respondsToSelector:@selector(keywords)]){ | |
[dict setObject:[[userActivity keywords] allObjects] forKey:@"keywords"]; | |
} | |
#pragma clang diagnostic pop | |
} | |
#endif | |
[[NSNotificationCenter defaultCenter] postNotificationName:KTiHandOff object:self userInfo:dict]; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment