React Native Android application does't ask to use geolocation from user - react-native

In my React Native application I use geolocation. IOS app asks permission for using user geolocation but Android app automatically allows user's geolocation. How can I ask permission for it.

I don't think accessing location is enabled by default, you have to enable it as described in the Geolocation docs.
In your AndroidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
To show the dialog asking for the permission on Android M (6.0) and newer, use the PermissionsAndroid module.

Related

Will an Android app only receive push notifications is the app was downloaded from the Google Play Store? (React Native Expo)

I'm using Expo push notifications. Push notifications work fine in Expo Go and for apps on published to the Google Play store. But when I create an APK file and download it directly onto my Android phone, NOT through the Google Play store, the push notifications I send are not received.
Will push notifications only work for apps published to the Google Play store? Or is there a way to receive push notifications for apps downloaded directly onto an Android phone without being published to the Google Play store?
Depending on your android version and rom you have to open the app setting's (for me long press app icon).
Select settings
Choose notifications
Enable notification for this app
I forgot to import { Platform } from 'react-native'.
Also, I needed to upload Android server api key credentials which can be found in Firebase Console in your project settings under Cloud Messaging. Here is how to upload the server api key credentials in the terminal:
expo push:android:upload --api-key <your-token-here>
Documentation can be found here under "Uploading Server Credentials": https://docs.expo.dev/push-notifications/using-fcm/

how to grant permission for background location react native

I'm struggling to publish the app to google play because of that permission request.
I have provided location permission asks. but it has only 2 label options allow/reject.
as far as I see I need to put getBackgroundPermissionOptionLabel() with more options.
followed: https://developer.android.com/training/location/permissions#foreground
how do I do that on react native?

Expo Notification askAsync() - Is there a way to customize the message?

I am using EXPO on a react native project and want to ask the user for push notification permission.
When I use the const {status} = await Permissions.askAsync(Permissions.NOTIFICATIONS); the message that appears is
"Expo" would like to send you notifications. Notifications may include sounds, badges, alerts and icon badges. These can be configured in settings.
My end user doesn't know what "Expo" is, they just know the app name. Is there a way for me to customize the "Expo" part to the app name?
How have people handled this when their app is ejected and push to the app store?
You can find the answer in here: https://docs.expo.io/distribution/app-stores/?redirected
Which says:
System permissions dialogs on iOS
If your app asks for system permissions from the user, e.g. to use the device's camera, or access photos, Apple requires an explanation for how your app makes use of that data. Expo will automatically provide a boilerplate reason for you, such as "Allow cool-app to access the camera", however these must be customized and tailored to your specific use case in order for your app to be accepted by the App Store. To do this, override these values using the ios.infoPlist key in app.json, for example:
"infoPlist": {
"NSCameraUsageDescription": "This app uses the camera to scan barcodes on event tickets."
},
The full list of keys Expo provides by default can be seen here. Unlike with Android, on iOS it is not possible to filter the list of permissions an app may request at a native level. This means that by default, your app will ship with all of these default boilerplate strings embedded in the binary. You can provide any overrides you want in the infoPlist configuration. Because these strings are configured at the native level, they will only be published when you build a new binary with expo build.
You probably use Expo Go to develop your app , when you create standalone app (when you deploy the apk) it will show the app name that you specified in app.json.

How can I request iOS storage permission in react native?

I have found a package called react-native-permissions which gives most of the permissions in Android and iOS. Currently it is not supporting Storage permission in iOS. How can I request iOS storage permission in react native?
You need to add the following fields in your plist.
<key>NSPhotoLibraryAddUsageDescription</key>
<string>*your app name* would like to save photos from the app to your gallery</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>*your app name* would like to access your photo gallery for uploading images to the app</string>
If you want to save data you don't need any permission for that on iOS, it is allowed by default. Source It is the only reason why it is not supported by react-native-permissions.

How can I check if push notifications were disabled in React Native using PushNotificationIOS?

I'd like to determine if push notifications were disabled by a user using React Native with PushNotificationIOS.
PushNotificationIOS has the method checkPermissions, but this method only tells me whether notifications are enabled.
I would like, using React Native, to tell if my app prompted the user to enable notifications and the user denied the permission, or if the user independently went to settings and disabled notifications.
In native code, you'd use UNUserNotificationCenter and check getNotificationSettings for authorizationStatus with value .denied.
Thanks.
I can suggest to you try this library. This library have all features that you mention above. For me it's work great, hope for you too.