3

I'm trying to get a custom push with Urban Airship and phonegap to redirect view. Basically I want to send a custom data push that would look like:

"aps": {"alert": "Hello!", "extra":{"targetURL":"www.google.com"}}

and for the app's view to be redirected to the targetURL.

Right now my notification handler is:

-(void)handleNotification:(NSDictionary *)notification withCustomPayload:(NSDictionary *)customData{

UALOG(@"Received an alert with a custom payload");

NSString *URL = [customData objectForKey:@"targetURL"];

//UIWebView *view = [PhoneGapDelegate 
AppDelegate *mainDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate];


[mainDelegate redirectTo:URL];

}

the redirect function looks like the following and is in the AppDelegate:

- (void) redirectTo:(NSString *){
URL{NSLog(@"In redirect in cocoa");
[[self webView] stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"goTo('%@');", URL]];
}

This code does call the javascript function i use to redraw the view but i cannot get it to redraw once i send the notification. Any help in making the view redraw will be helpful either doing it this way or another more effective way would be appreciated.

arhimmel
  • 81
  • 1
  • 5

1 Answers1

0

I'm not sure if this is your problem but I just found out how to send the custom notification payload and it's of this form:

"aps": {"alert": "Hello!"}, "targetURL":"www.google.com"

Then your code should hit your handler and thus call your redirect function.

Evan Layman
  • 3,691
  • 9
  • 31
  • 48