first your scheme usage is wrong... CFBundleURLSchemes is to refer to your application from outside, not intended specifically for your extension. a better usage would be:
let url = URL(string:"yourAppName://TodayWidget?key=value")
let url = URL(string:"yourAppName://action?param1=value1¶m2=value2")
then you can identify the source or action ...
here's code to get a dictionary from your params (url is from application:openURL)
adapt the validations to your needs.
if (!url) return NO;
if ([url.absoluteString rangeOfString:@"://"].location == NSNotFound) return NO;
if ([url.absoluteString rangeOfString:@"?"].location == NSNotFound) return NO;
NSMutableDictionary* queryString = [NSMutableDictionary dictionaryWithCapacity:1];
__block NSMutableDictionary* paramDict = [[NSMutableDictionary alloc]init];
[paramDict setValue:[url scheme] forKey:@"protocol"];
[paramDict setValue:[url absoluteString] forKey:@"url"];
[paramDict setValue:[[url.absoluteString componentsSeparatedByString:@"://"][1] componentsSeparatedByString:@"?"].firstObject forKey:@"path"];
[paramDict setValue:queryString forKey:@"parameters"];
NSString* urlString = [url.absoluteString stringByRemovingPercentEncoding];
NSString* paramString = [urlString componentsSeparatedByString:@"?"][1];
NSArray* params = [paramString componentsSeparatedByString:@"&"];
for (NSString* param in params)
{
NSArray* paramArray = [param componentsSeparatedByString:@"="];
if (paramArray.count != 2) {
NSLog(@"Malformated url:%@", urlString);
continue;
}
NSString* key = paramArray[0];
NSString* value = paramArray[1];
if (!key.length | !value.length) {
NSLog(@"Malformated key %@ value %@ in url:%@", key, value, urlString);
continue;
}
[queryString setValue:value forKey:key];
}
NSLog(@"%@", [paramDict toJSONString]);