Having trouble with Phonegap notifications - specifically navigator.notification.alert
and navigator.notification.confirm
- not functioning properly when utilizing shouldStartLoadWithRequest
for URL request processing.
Sample Javascript code:
function onBodyLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {
navigator.notification.alert("Cordova is working");
}
Objective C code snippet:
- (BOOL)webView:(UIWebView *)webView2
shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType{
if ([[[request URL] absoluteString] hasPrefix:@"js-call:"]) {
// Extract the selector name from the URL
NSString *requestString = [[request URL] absoluteString];
NSArray *components = [requestString componentsSeparatedByString:@":"];
NSString *function = [components objectAtIndex:1];
NSLog(@"the function name is %@",function);
// Call the given selector
[self performSelector:NSSelectorFromString(function)];
// Cancel the location change
return NO;
}
return YES;
}
Seeking assistance to resolve this issue. Thank you.