简体   繁体   中英

Communicating with objective-C from JS in phonegap?

I need to get the iCloud directory, so I'd like to have some iOS bridge to get the directory name.

    NSURL *ubiq = [[NSFileManager defaultManager]
                   URLForUbiquityContainerIdentifier:nil];
    if (ubiq) {
        NSLog(@"iCloud access at %@", ubiq);
    } else {
        NSLog(@"No iCloud access");
    }

This gives me the url, but I'd like to be able to do something like this:

window.ios.getICloudDirectory(function(directory){
//do stuff with the iCloud directory
});

What is the easiest and least-code method of doing this?

Create a plugin. This is the fastest way to go.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM