Prevent Android 13 from showing the notification permission prompt - android

Android 13 automatically asks the user if they would like to allow the app to send them notifications.
My app does not show any notifications, therefore it doesn't make any sense to ask the user for push notifications at this time. I would like to defer this prompt for when we actually have notifications and a well defined permissions UX.
How do you tell Android 13 to not ask for the permission automatically?

My app does not show any notifications
Something — perhaps a library — is doing something related to notifications, such as setting up a notifications channel. That will trigger the notification permission prompt.
IOW, the existence of that prompt means that something is working with notifications. You can tell this by creating a scrap "Hello, world!" project in your IDE, running it on your Android 13 device, and noticing that the notification permission prompt does not appear.
How do you tell Android 13 to not ask for the permission automatically?
Remove the code that is working with notifications. For example, you might check your app's page in Settings and see if any notification channels are set up, and see if their names help you identify what code is creating those channels.

Try to upgrade targetSdk and compileSdk to 33
If your notification feature is optional for users, you could migrate apps to Android 13 to control the timing of requesting Notification runtime permission by yourself. (System won't auto ask for notification permission on android 13 devices)

Related

What happens in Android if you run code that requires a permission but fail to have it?

I am talking about the quality issue (bug) that an Android app needs a permission that is declared in the Manifest, but fails to request it from the user at the appropriate time and executes the code without the necessary permission. This was not possible in older Android versions (user accepts all permissions in bulk), but seems to be possible when using newer versions that copy Apple in most regards.
At least during testing one can start background services and use bluetooth without any alert by Google popping up. Is that different for apps in production?
Does the app crash with an Exception?
Does the code get executed?
Does the app get rejected in review? (Always?)
Does the app get delisted from the store?
Does it depend on Android's Version?
I deal with an age old app that has bluetooth discovery code to find and connect to dedicated hardware, that is rarely used via a cordova plugin triggered by content. There is old altbeacon code potentially activated that may even need access background location (https://developer.android.com/guide/topics/connectivity/bluetooth#Permissions). It will take some time to get this dead code up to quality. Definitely more time than the week we have.
Does the app crash with an Exception?
yes if you try to have operations depends on returned date witch is null
Does the code get executed?
code will execute with exceptions because data access denied you can check if permission granted or not and add scenario for each state
Does the app get rejected in review? (Always?) not sure but with crashes there is high potential to get rejected
Does the app get delisted from the store?
depends on why and how you are using data
Does it depend on Android's Version?
yes access data and permissions changing point is android oreo
My tests with Bluetooth permissions revealed the following: Required permissions are BLUETOOTH_ADMIN, BLUETOOTH and for VERSION_CODES.Q additionally Manifest.permission.ACCESS_BACKGROUND_LOCATION (see: https://developer.android.com/guide/topics/connectivity/bluetooth#Permissions).
BLUETOOTH_ADMIN, BLUETOOTH do not show any system alert-dialogue to the user. In Android Q+ if you fail to check for the required ACCESS_BACKGROUND_LOCATION permission, nothing happens and your code executes without exception (mine did execute an UART command on hardware with Samsung tablet). The app passed review although the check is missing (of course I will fix that ASAP).
Note: the doc is ambiguous and states: "Services running on Android 10 and higher cannot discover Bluetooth devices unless they have the ACCESS_BACKGROUND_LOCATION permission." Probably general scanning while the app is active could be allowed. In that case missing exception would be explained.

Huawei Android devices - properly requesting permissions for background locations

We develop an application which requires several permissions in order to get the user’s location while in the background.
We are having problems requesting the required permissions on Huawei devices. It seems that in addition to location permission and white listing the app from battery optimizations, an additional step is required in order to disable battery optimizations and enable auto launching:
The problem is we found no way of automatically requesting permission from the user, and the only way we found is having the user manually go to these screens and change the settings.
We did find a shortcut to take us “half way”, to the application settings:
Intent intent = new
Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.parse("package:"+context.getPackageName()));
But multiple non intuitive actions are still required from the user.
Our aim:
We would very much like to make the process easier for the user. Optimally, to have a system dialog appear which asks the user for the permissions, instead of having him manually change the settings, much like the whitelisting of normal Android devices:
Is it possible using a Huawei specific SDK extension?
If (1) is not possible, at the very least we need a way to know if the user changes these settings or not. Currently we don’t know and cannot inform the user if the application works properly or not!
Are you expecting that your app displays a permission popup so that users can easily assign related permissions to your app?
If yes, you can integrate HMS Core Location Kit into your app. Before performing an operation requiring a permission, your app dynamically checks its permissions.
If your app does not have the required permission, it will display a popup to prompt the user to assign the permission. You can implement the popup with few code lines and users can easily assign permissions in the popup. For details, visit https://developer.huawei.com/consumer/en/doc/development/HMS-Guides/location-guidev4.
In addition to dynamic authorization, do not forget to apply for static permissions in the Manifest file.

Codename One sendSMS on Android

With the recent Android policy updates, sendSMS no longer works properly. In our app, we have buttons to allow users to call or send messages to their contacts. The buttons call
Display.getInstance().dial(phoneNumber); and Display.getInstance().sendSMS(phoneNumber, message, true); respectively.
Currently, both options redirect to my default phone or sms app with the phone number (and message) in place. This would mean our app doesn't actually need the SEND_SMS permission since it's not doing the actual sending. However, if I remove the permission when building the apk in Android Studio, the SMS button no longer functions.
Is there any workaround for this? At the moment we're not able to deploy our app on the Play Store with this permission.
We will remove the SMS permission from the coming update.
We'll fix the Android port so sendSMS with the true argument should work correctly. Unfortunately we don't have an immediate workaround other than using native interfaces. This fix should be available this Friday (March 8th 2019).

Expo Push Notifications not popping in Android phones (Floating Notifications)

EDIT: I discovered these are known as FLOATING NOTIFICATIONS. Anyone knows how to enable them by default from the app (through a permission etc) on an Android device?
I am currently testing push notifications on an Android device and noticed that although I get the push notifications, they are not popped up on the screen but stay in the background (I need to drag down the top status bar as per picture). I see this as rather useless as the user is not really notified if he's using the phone:
On iPhone, the pop up displays correctly with no issues whatsoever.
I've finally made it work using Expo.Notifications.createChannelAsync using priority: "max" and when sending a message add channelId: "mychannel".
To show a so called floating notification, app must have the permission SYSTEM_ALERT_WINDOW.
A permission is something given by the user. So, there is no way to enable them by default from the app. What you can do is to take user to the settings page.
Check if you already have the permission
The recommended way to do this is using Settings#canDrawOverlays(Context).This permission is introduced only in API level 23. Therefore as per doc, it there is no need to check the permission in older devices.
However it is seen that this won't work well as expected in some pre-Marshmallow devices like Xiaomi Mi 2. So is better to do it as shown in this post.
Take user to the settings page if there is no permission
If the app targets API level 23 or higher, the app user must explicitly grant this permission to the app through a permission management screen. The app requests the user's approval by sending an intent with action Settings.ACTION_MANAGE_OVERLAY_PERMISSION.
Intent intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setData(Uri.parse("package:" + context.getPackageName()));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
context.startActivity(intent);

Does all the Android apps have notification enabled by default

I’m looking out for a solution in React native to check if notifications is enabled for Android. If not, enable them. I found out a library (React-native-android-permission-library) which works great. But my question here is I find that notification is enabled by default in our app without specifying in Manifest.xml. I did a bit of reading and found Access_Notification_policy is used for notification which is added as part of API level 23 and that has been considered as Normal permission.
My question here
1. Does all Android apps including our app have notification enabled by default. Is this always be the case?
2. Even lot of permissions are considered as normal, still I believe that it’s not enabled by default.
2. In case notifications are enabled by default, I’m not sure if I still need to check if notification is enabled?
3. Also found somewhere that notification is enabled when your device is registered for location. If this is the case, Can I assume that all devices are registered for location by default.
Please advise.

Categories

Resources