I am using google_maps_flutter and location plugins to show user's location in my app.
I want to enable gps permissions from my app itself, it seems trivial but when I tried using plugins (like permission plugin), I am able to enable only app permissions to access location and not the gps permissions. I am able to check the location and give a toast if permission isn't there but how do I enable it from app itself?
I think what you want is to open the location settings, rather than the permissions, which is included in the AndroidManifest. Also most geolocator plugins have a request permissions method in them, if you need that, rather than the settings.
Assuming you want the user to open and turn on the location, in Android, I think you would need to create an intent, so it would look something like this..
import 'package:android_intent/android_intent.dart';
Then in your class...
static Future makeLocationDialogRequest() async {
final AndroidIntent intent = new AndroidIntent(
action: 'android.settings.LOCATION_SOURCE_SETTINGS',);
intent.launch();
}
And then later maybe do a check using your plugin of choice to check if the user did in fact enable the location.
Note, this is for Android only, so do a check beforehand if its an Android device,eg
var platform = Theme.of(context).platform;
With further info on android_intent here
Usually, you only need to include the permissions on the manifest.xml file (on Android), such as:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location.gps" />
<uses-permission android:name="android.permission.INTERNET" />
or on iOS by adding this values to your info.plist
NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
However, if you want to check or ask for a particular permission in runtime you can do so with simple_permissions package.
Related
I want to add Google Drive integration to a browser add-on I developed. Basically I want to share user settings between devices, and the settings files are too big to fit inside the 100KB limit for the storage.sync API.
But when I go to my API console and try and activate permissions for the Drive API, I get this:
Browser apps (and Android apps) aren't allowed to access app data. That's not just a warning, you actually can't continue the process until you choose a different platform. Weirdly, I can go ahead if I select "User data" (so user data is less sensitive than app data??)
What I like about app data over user data is that, if I understand correctly, app data goes in a hidden folder uniquely tied to your app, whereas user data goes in the actual user's drive. I don't want my app to have access to the broader drive, I don't want to risk messing their data up and I don't want them to see my app's config files every time they access their drive.
How can I get this "hidden folder" behavior from a browser addon?
Try the solution from this related SO post.
To be able to use your Application Data folder, request access to the following scope:
https://www.googleapis.com/auth/drive.appdata
I have the quickstart working where it lists the files, and I have the code to download the file, but I do not know where/how to add the permissions to the OAuth2.0 request to allow the code to download files. I've been all over the console and cannot find it.
Google does not use a Web UI to manage these ahead of time.
The scopes are a space-seperated string passed to client.flow_from_clientsecrets(). Adding new scopes will cause the user to have to confirm access.
I am building a chrome app for Digital Signage where I need the user to select some files from a particular folder (preferably in the app's directory) i.e audio, videos, photos which should be created by the app on install.
The sample code provided by Google requires that the user navigates to a folder like this
chrome.fileSystem.chooseEntry({type: 'openDirectory'}, function(theEntry) {
if (!theEntry) {
output.textContent = 'No Directory selected.';
return;
}
// use local storage to retain access to this file
chrome.storage.local.set({'chosenFile': chrome.fileSystem.retainEntry(theEntry)});
loadDirEntry(theEntry);
});
However, my app simply needs the name of files in that (say Video) known directory for the user to build a playlist, rather than actually selecting a video file.
Is this supported in chrome.fileSystem API? Any pointers to how I cold get this done?
It sounds like you should be using either the app's sandboxed file systems, or the app's install folder itself.
The sandboxed file systems allow the app to store whatever data it wants, in whatever structure it wants. There are two to choose from: persistent or temporary. Temporary may be cleared at any point in time. To use these check out this article. Some of its code may be out of date with the spec. Note also apps need to request the unlimitedStorage to use these.
The install folder itself can be used in a read only way. To do this you use chrome.runtime.getPackageDirectoryEntry.
I want to use the Google drive sdk to save data from my app in the user's own Google drive account. This will mean that the developers of the app (i.e. me) won't have access to sensitive data that the user is storing.
I have found some docs about how to do this (the app will be a Google app engine app) but I was wondering if I can lock this data or hide it completely so that a user can't go in and edit the data and possibly cause problems.
I know that Android apps that use Google drive do not leave any visible files that I can see when I go to my drive account.
Thanks
When creating the file, set the hidden label to True. This will hide the file from most user views. Note that it doesn't completely prevent the user from finding and modifying the file if they own it.
If you need the file to be uneditable by the owner, your app will need to own it and only grant the user view access.
In Google Play Services 4.3, they added an "Application Folder." This is designed to allow applications to store data in a user's drive without allowing them to modify this data. It's available for android and web, don't see it listed for iOS.
Is it possible to use geolocation API in chrome extension without including the "geolocation" permission in manifest.json?
Like can we ask permission through the background.html file which runs the extension?
You can use it in a content script without declaring a permission.
This would trigger a standard notification bar asking if you want to allow current site (not your extension) to access geolocation. If user allows it, you can then pass received geolocation position to a background page for further processing.
This approach might work if your extension is injecting a content script to a single domain, otherwise user would have to allow geolocation for each domain they visit.
The code should look like:
navigator.geolocation.getCurrentPosition(function(position) {
console.log("Latitude : "+position.coords.latitude+":"+"Longitude : "+ position.coords.longitude);
});
Nope:
"An array of permissions that the extension or app might use. Each permission can be either one of a list of known strings (such as "geolocation") or a match pattern that gives access to one or more hosts. Permissions can help to limit damage if your extension or app is attacked."
http://code.google.com/chrome/extensions/manifest.html
...and here:
Your physical location "geolocation" permission Allows the extension to use the proposed HTML5 geolocation API without prompting the user for permission.
http://code.google.com/chrome/extensions/permission_warnings.html
Actually, after looking at it a bit more you can but the user will be prompted for permission:
http://www.html5rocks.com/en/tutorials/geolocation/trip_meter/
...and this page from Google says you can use this API and others:
http://code.google.com/chrome/extensions/api_other.html