views:

136

answers:

0

hi havent found the solution yet in the forum.

i want to call a function i created in the index.html via a objective-c function. As explained in stringByEvaluatingJavaScriptFromString

so the network detection doesnt work for me

the function gets called but no javascript is called in the index.html here is the code i use

- (void)updateReachability:(NSString*)callback
{
    NSString* jsCallback = @"navigator.network.updateReachability";
    if (callback)
        jsCallback = callback;

    NSString* status = [[NSString alloc] initWithFormat:@"%@({ hostName: '%@', ipAddress: '%@', remoteHostStatus: %d, internetConnectionStatus: %d, localWiFiConnectionStatus: %d  });", 
                        jsCallback,
                        [[Reachability sharedReachability] hostName],
                        [[Reachability sharedReachability] address],
                       [[Reachability sharedReachability] remoteHostStatus],
                       [[Reachability sharedReachability] internetConnectionStatus],
                       [[Reachability sharedReachability] localWiFiConnectionStatus]];


    [webView stringByEvaluatingJavaScriptFromString:status];
    [status release];
}

If i log the status the string i see can be executed in the index.html file, the syntax is ok. but it doesnt get called

if i do alert( etc... it gets called...

need some help pls, because network detection is a kill criteria to publish a app!!!

Adrian

PS:thx kennyTm ;-) im new to this forum