I've got a cordova project and need to authorise a google maps API call from our index.html page. I've successfully done this for Android by adding "file:///android_asset/www/default/index.html" to our authorised URLs. However I can't seem to get the file path right for our iOS build. The index.html is in a www/default folder, so I tried file:///www/default/index.html however this doesn't work, any ideas?
I think that is what you're searching:
NSString* path = [[NSBundle mainBundle] pathForResource:#"www/index" ofType:#"html"];
Related
I am using google sign-in in an app using react-native-google-signin. I have a dev and a prod google API project set up in the backend.
I want to use the separate GoogleService-Info.plist for dev and prod in my react-native app.
How can I configure GoogleService-Info.plist depending upon the environment?
You need to config based on your env.
NSString *firebasePlist = [[NSBundle mainBundle] pathForResource:#"GoogleService-Info" ofType:#"plist"];
#if DEV
firebasePlist = [[NSBundle mainBundle] pathForResource:#"GoogleService-Info-DEV" ofType:#"plist"];
#endif
FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:firebasePlist];
[FIRApp configureWithOptions:options];
If you have configured your project with https://console.developers.google.com
There is no need to configure anything in your code.
For ANDROID by default, you can set up 3 environments
DEV
RELEASE
Google Play(Production)
ANDROID provides separate SHA-1 Keys for the above-mentioned environemnts.
With these SHA-1 keys, you can create 3 Oauth projects. Now you have 3 Oauth google projects that you can configure with 3 separate branches(dev, release, prod) of your project.
FOR IOS
You can create as many Oauth google projects as you like.
Just keep the GoogleService-Info.plist of your Oauth google project depending upon the environment in the ios folder at the time of making the build.
I need to access a file from my main app in my share extension is that possible? The file is the "bundle" for distribution for a react native iOS app, something like
jsCodeLocation = [[NSBundle mainBundle] URLForResource:#"main" withExtension:#"jsbundle" subdirectory:#"../myMainProject"];
If I copy and paste the main.jsbundle file on my share extension it works fine.
Or should I place this main.jsbundle in an app group so both app and extension can use it?
An app and its extensions can only share data over a common app group folder, and both must be added explicitly in Xcode to that group.
If your JavaScript bundle is static and is delivered with your app, you max place it as a resource into a shared framework, and add this framework to both app and extension. So you can access this bundle by
jsCodeLocation = [[NSBundle bundleWithIdentifier: <framework identifier>] URLForResource:#"main" withExtension:#"jsbundle"];
Note: You shouldn't access the contents of the parent folder of a bundle folder.
Hello I have an app in my code that loads a file into a Bluetooth device, but it seems like if I change that file for the new version of the app it doesn't update it if I just reinstall it. I have to actually delete the app and install it again. Anyone know why? Is there some cache storing?
NSString *fileInDocuments = [documentsDirectory stringByAppendingPathComponent:#"samplefile_pack.bin"];
NSLog(#"File: %#", fileInDocuments);
if ([fileManager fileExistsAtPath:fileInDocuments ] == NO) {
NSString *resourcePath = [[NSBundle mainBundle] pathForResource:#"samplefile_pack" ofType:#"bin"];
[fileManager copyItemAtPath:resourcePath toPath:fileInDocuments error:&error];
}
I'm assuming v1 of your app has the same code as the v2 of your app posted in your question. Assuming this is true, the behavior you see makes perfect sense.
A user runs v1 of your app. The file isn't in the Documents folder so it gets copied from the app bundle. Now, every time they run your app, the file exists and that copy in Documents is used.
Now the user updates to v2 of your app. The same check is made. The file already exists in Documents so nothing is copied.
Since your question implies that you want an updated copy of this file installed the 1st time v2 of the app is run, you need to detect whether the user currently has the file from v1 or v2 in the Documents folder.
There are a few ways to solve this. One option is to rename the file to something like samplefile_pack2.bin. Then your check can be for the new file name. You can also check for the old one and delete it if it makes sense.
Need to install a pre-built couches lite database in my IOS application, for that I need to locate the database's .cblite file.
When I go to [[NSBundle mainBundle] bundlePath] . I cannot find anything.
You can use http://simpholders.com/ to locate the application folder in a simulator running the app with Couchbase Lite.
The cblite file and folder to store the attachments are in the folder returned by SimPholders in Library/Application Support/CouchbaseLite.
Once you have the canned database, see this documentation guide to use it as a resource in your app and to set it up with the replaceDatabaseNamed:withDatabaseFile:withAttachments:error: method.
I just started to test my Phonegap application on iOS Simulator but I've got some problems:
First thing I did was getting the root path:
requestFileSystem(LocalFileSystem.PERSISTENT, 0, onSuccess, onError);
So I get something like this: Users/christophe/Library/Application Support/iPhone Simulator/5.1/Applications/CODE/Documents
Then I just figured out that I need to add file:// before this path to use the resolveLocalFileSystemURI() otherwise the file is not found.
So I tested my Download function like this:
download(url, "file://"+root+"folder/siteList.xml", callbacks)
But I got an error telling me that the filePath or the URL is wrong. So, I checked the URL: no problem.
The problem comes from the FilePath.
The "folder" I added blocked the download.
If I download the file in the root folder:
download(url, "file://"+root+"/siteList.xml", callbacks);.
It worked.
How can I download in an other folder ?
I already tried this on Android. There's no such problem.
Thank you