Android: add permissions to push out notifications - android

I'm developing an Android app and I plan to push out notifications to the user in a future version. However, I want to add the permissions for it already on the current version.
How do I do this?
For example, in my AndroidManifest.xml file, should I add something like:
<permission
android:name="...permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission
android:name="...permission.C2D_MESSAGE" />

Yes, GCM permission
<permission android:name="<your-package-name>.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="<your-package-name>.permission.C2D_MESSAGE" />
is correct. BUT
You should not add any permission into manifest, which your app is not
using. Better to add permission in the same version when you will
introduce PUSH notification feature.

Related

In android Manifest how do you declare that a permission is not required?

Say I have these permissions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission
android:name="android.permission.PACKAGE_USAGE_STATS"
tools:ignore="ProtectedPermissions" />
I would like to tell the Play Store that these permissions are not required and are not to be used for filtering out devices. I found that with some permissions like bluetooth you can add the <uses-feature tag and then to that add android:required="false". For example:
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<!-- Tells the Play Store that the above two permissions are not required -->
<uses-feature
android:name="android.hardware.bluetooth"
android:required="false" />
However I found no features to declare for any of the permissions I listed in the beginning of this post. So how am I supposed to tell the Play Store that they're not required?
So how am I supposed to tell the Play Store that they're not required?
You don't. No devices will be filtered out based on those permissions.
I would like to tell the Play Store that these permissions are not required and are not to be used for filtering out devices
No permissions are used directly for filtering out devices. As you noted, some permissions imply features, and you can declare that the features are not required.
I would like to tell the Play Store that these permissions are not
required and are not to be used for filtering out devices.
Don't worry! If your next update/package don't require some permissions, just remove those permissions from the mainfest.xml, and done. If you still have doubt, you can see the number of compitable device models during creation of release in your console.
I found that with some permissions like bluetooth you can add the
<uses-feature tag and then to that add android:required="false".
They are all for feature-based filtering and not for permissions. Because, features might be critical for some apps to work. If an app uses a feature which is not critical for its functionality, required=false might be helpful.
You can use like that:
<uses-permission android:name="android.permission.INTERNET"
tools:node="remove"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"
tools:node="remove"/>

IONIC Capacitor Remove the unnecessary permissions in iOS & Android

When I create a project using Ionic Capacitor, automatically both iOS (info.plist) and Android(AndroidManifes.xml) have some default permissions:
AndroidManifes.xml Permissions:
<!-- Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Camera, Photos, input file -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Geolocation API -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location.gps" />
<!-- Network API -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Navigator.getUserMedia -->
<!-- Video -->
<uses-permission android:name="android.permission.CAMERA" />
<!-- Audio -->
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
Info.plist Permissions:
<key>NSCameraUsageDescription</key>
<string>To Take Photos and Video</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Always allow Geolocation?</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Allow Geolocation?</string>
<key>NSMicrophoneUsageDescription</key>
<string>To Record Audio With Video</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Store camera photos to camera</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>To Pick Photos from Library</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
Let's say my app doesn't need Camera access, If I remove it from AndroidManifest.xml, my app builds successfully and is posted in PlayStore without that permission, but if I remove anything from Info.plist after uploading through xCode I get email notification that I should add that permission that I just removed.
What is the correct way to do this, should I change other files in iOS?
On iOS they are not permission, they are usage descriptions.
Usage descriptions are an additional text explaining why your app needs a permission at the moment the app request it.
Since Capacitor ships all the core plugins and some of them request permissions, Apple code scanner detects the code and warns you to make sure you didn't forget about them. It's just a warning, you shouldn't worry, but also, there is no harm if you leave them there.
On Android on the other hand, you can remove the permissions you don't use.

How to remove location permissions in react-native app?

I uploaded my react-native app on PlayStore and I saw that my app "may request permission" to access location.
I do not use location services on application so I want it removed. Is there anyway to find out where location services are potentially used? AndroidManifest.xml does not mention any location services. How do I remove this permission?
I want the "may request access to Location" be removed from the permissions in Play Store when it is uploaded.
Try adding this to your AndroidManifest:
<uses-permission tools:node=”remove” android:name=”EnterPermissionNameHere” />
the important part is the attribute tools:node=”remove”this way it will try to remove the permission if its added from somewhere within the app. Just Make sure to replace "EnterPermissionNameHere" with the exact permission name for example "android.permission.ACCESS_FINE_LOCATION"
Maybe this will fix your problem
adding this
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.blah.blah">
.......
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" tools:node="remove" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" tools:node="remove" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" tools:node="remove" />
reference : https://support.google.com/googleplay/android-developer/answer/9888170
May be some of third party used locations services which you integrated in your app.
you should remove like this
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"
tools:node="remove" />
Increase apk version and upload in play store .if its not accept then go to appeal for playstore team manually.
for more details Refer Here

why android.hardware.telephony feature is being added automatically in android app

While releasing the apk to play store, I found out that the my app requires the android.hardware.telephony feature but I haven't added it in manifest anywhere. I have also check the merged manifest in android studio and it also does not contain this feature so I think no third party sdk is adding this. What could be the source of this feature?
For reference, I have following permissions declared in the manifest:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Also, when I make it optional using below code, the app is available on devices without this feature:
<uses-feature
android:name="android.hardware.telephony"
android:required="false" />
So why is required by default without adding it anywhere?
Google Play automatically adds some features, depending on which permissions you have requested.
As you have requested READ_SMS and RECEIVE_SMS permissions, this implies you use the telephony feature. So, Google Play reacts as if you had the following in your AndroidManifest.xml:
<uses-feature
android:name="android.hardware.telephony"
android:required="true" />
When you manually add this and declare it required="false", this tells Google Play that whilst you do ask for the permission, you can handle the case where the user does not have the telephony feature.
This is confirmed via this note in the docs:
Note: Some system permissions implicitly require the availability of a device feature. For example, if your app requests permission to access to BLUETOOTH, this implicitly requires the FEATURE_BLUETOOTH device feature.
The full list of permissions and the feature requirements implied is available here, and includes your situation:
Finally, with your ACCESS_COARSE_LOCATION you are also declaring a feature requirement on android.hardware.location, just for your information.
There's also further detailed information over on the GameDev StackExchange.
One or more of the dependencies / modules / libraries your project is using is adding that requirement to your Android Manifest.
To investigate open your main Android Manifest file in Android Studio, and click on the Merged Manifest tab at the bottom of the page.
This will show you a view of the final merged Manifest, along with sources of each line.
Read more about this here: https://developer.android.com/studio/build/manifest-merge#inspect_the_merged_manifest_and_find_conflicts
HOW TO FIX
If you wish to avoid adding that requirement to your final Manifest, you can use Node Markers in your Manifest to control how the merge works.
Read more about Node markers here: https://developer.android.com/studio/build/manifest-merge#node_markers
e.g. try this:
<uses-feature
android:name="android.hardware.telephony"
android:required="false"
tools:node="replace" />

C2D permission error

I'm building an app and I want to send push notifications to the users of this app, so I use the PushBots services.
In their guide, they say to put these permissions in the manifest:
<!-- GCM connects to Google Services. -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission android:name="com.example.sampleapp.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.example.sampleapp.permission.C2D_MESSAGE" />
<!-- This app has permission to register and receive dataf message. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
But in the new permission request system, I have to request every single permission.
So now I'm asking these permissions in my app:
-location permissions (I use map activity).
-accounts permissions (PushBots said it is required).
I've tried to run my app, and this is the error I get:
java.lang.IllegalStateException: Application does not define permission com.giladneiger.haerev.permission.C2D_MESSAGE
How can I request a permission for this? There is no option for it, and my app will request so many permissions that the user will lose his patience for it.
What do I have to do with this error?
You should use your package name com.giladneiger.haerev instead of com.example.sampleapp in the lines

Categories

Resources