Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android M Permissions with Parse Push Notifications

I am still a little confused about the new runtime permissions model. Would any of the following required permissions for Parse push notifications (GCM) require a runtime permission ?

<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<uses-permission android:name="android.permission.WAKE_LOCK" />

<uses-permission android:name="android.permission.VIBRATE" />

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

<uses-permission android:name="android.permission.GET_ACCOUNTS" />

<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

 <permission android:protectionLevel="signature"       android:name="com.parse.starter.permission.C2D_MESSAGE" />

<uses-permission android:name="com.parse.starter.permission.C2D_MESSAGE" />
like image 467
Taylor Courtney Avatar asked Aug 20 '15 04:08

Taylor Courtney


2 Answers

Among the permissions you listed above, GET_ACCOUNTS requires runtime check because its protection level is dangerous.

But the thing is, while GET_ACCOUNTS permission is no longer needed for GCM to work (starting with 7.5 Play Services, I guess), it's still needed if you're using Parse Push Notifications.

It seems that in order for Parse to provide full compatibility to whole range of android powered devices (i.e. non GCM based devices like Kindle Fires, where GCM isn't supported and they have to fall back to their own persistent socket implementation and of course the devices with 4.0.3 and below), Parse still needs this permission and some other ones.

A guy from Parse mentioned that:

We require it being requested, aka being in AndroidManifest.xml, but don't require it being granted.

the issue is in discussion, you might want to take a look at these topics :

https://github.com/ParsePlatform/Parse-SDK-Android/issues/129 https://parse.com/questions/android-use-only-gcm-dont-require-additional-permissions

like image 194
Can Elmas Avatar answered Oct 17 '22 15:10

Can Elmas


The GET_ACCOUNTS permission requires the permission to be checked at runtime, since it belongs to the dangerous permissions group (https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous).

The other ones are normal permissions, and will be granted as long as they are declared on the manifest file (https://developer.android.com/guide/topics/security/normal-permissions.html)

If you realize you don't have the permission at runtime, you will need to request it, using the method requestPermissions(Activity yourActivity, String[] permissions, int requestCode). After that an non-customizable dialog will be shown to the user, requesting the permission.

Finally you need to override the onRequestPermissionsResult(int requestCode,String permissions[], int[] grantResults) method on your Activity, checking if the requestCode is the same requestCode you sent on requestPermissions and if the target permission was granted.

There are other cases you need to consider, like when the user does not grant the permission for the first time, and you still wanna ask him/her. In order to known how to handle this cases I suggest you read this: http://developer.android.com/intl/pt-br/training/permissions/requesting.html. It also have sample codes for requesting permissions and checking the results

like image 1
Caique Moreira Avatar answered Oct 17 '22 16:10

Caique Moreira