I am creating an application that uses a custom URL scheme, I configured everything and it works when I open the application, however now I want to be able to add one line to the URL so that the person who opens the application can see this line. I'm really struggling with this, can someone help me?
Here is my code
- (NSDictionary*)parseURLParams:(NSString *)query
{
NSArray *pairs = [query componentsSeparatedByString:@"&"];
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
for (NSString *pair in pairs)
{
NSArray *kv = [pair componentsSeparatedByString:@"="];
NSString *val = [[kv objectAtIndex:1]
stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[params setObject:val forKey:[kv objectAtIndex:0]];
}
return params;
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:@"Send Challenge"])
{
[FBWebDialogs presentRequestsDialogModallyWithSession:nil
message:[NSString stringWithFormat:@"I just scored %i points on this great game, called SumsUp. can you beat it?!", gameScore]
title:nil
parameters:nil
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error)
{
NSLog(@"Error sending request.");
}
else
{
if (result == FBWebDialogResultDialogNotCompleted)
{
NSLog(@"User canceled request.");
}
else
{
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:@"request"])
{
NSLog(@"User canceled request.");
}
else
{
NSString *requestID = [urlParams valueForKey:@"request"];
NSLog(@"Request ID: %@", requestID);
}
}
}
}];
}
I have a custom URL setting in P-List.
in my application i:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
UIAlertView *alertView;
NSString *text = [NSString stringWithFormat: @"url recieved: %@", url];
alertView = [[UIAlertView alloc] initWithTitle:@"" message:text delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
return [FBAppCall handleOpenURL:url sourceApplication:sourceApplication withSession:[PFFacebookUtils session]];
}
Hope this makes sense and someone can help me. If additional information is required, please let me know.
Thanks Graham
source
share