ios - How to declare the javascript in ios?

I'm invoking the javascript in below code,it's working perfectly,then I append that javascript with HTML content,when I'm checking the URL scheme in IF condition it fails.

- (void)connectionDidFinishLoading:(NSURLConnection *)connection

{

    if(_data)

    {
        NSString* content = [[NSString alloc] initWithData:_data
                                                  encoding:NSUTF8StringEncoding];

        [_data release];
        _data = nil;

        NSString *jsString = @"<script type='text/javascript'>\
        window.external =\
        {\
        'Notify': function(s) { document.location = 'acs://settoken?token=' + s; },\
        'notify': function(s) { document.location = 'acs://settoken?token=' + s; }\
        }\
        </script>";

        content = [jsString stringByAppendingString:content];
        [webView loadHTMLString:content baseURL:_url];
    }
} 


- (BOOL)webView:(UIWebView *)webView
shouldStartLoadWithRequest:(NSURLRequest *)request
 navigationType:(UIWebViewNavigationType)navigationType

{

    if(_url)

    {

        if([_url isEqual:[request URL]])
        {
            return YES;
        }

        [_url release];
    }
    _url = [[request URL] retain];
    NSString* scheme = [_url scheme];

   //Here I'm checking the condition

    if([scheme isEqualToString:@"acs"])
    {
        // parse the JSON URL parameter into a dictionary
        NSDictionary* pairs = [self parsePairs:[_url absoluteString]];
        if(pairs)
        {
            WACloudAccessToken* accessToken;
            accessToken = [[WACloudAccessToken alloc] initWithDictionary:pairs];
            [WACloudAccessControlClient setToken:accessToken];

            [self dismissModalViewControllerAnimated:YES];
        }

        return NO;
    }

    [NSURLConnection connectionWithRequest:request delegate:self];

    return NO;

}

Any ideas? Thanks in advance.

Answers


check this one ,

[webView stringByEvaluatingJavaScriptFromString:@"window.external =\
{\
'Notify': function(s) { document.location = 'acs://settoken?token=' + s; },\
'notify': function(s) { document.location = 'acs://settoken?token=' + s; }\
}"];

Need Your Help

Auto-loading declined when trying to use gdb with MPI?

c++ linux unix gdb mpi

I have a program that works serially, but when I try to use openMPI, I get the message

Document interaction controller shows options but when tapped on any option just hides menu

ios objective-c uidocumentinteraction

I am using the below code and getting true, but when tapping any option from the available, just hides the menu which is presented rather than opening the respective app.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.