androidnotificationsandroid-notificationsactivity-recognition

Android Notification: at your request android is blocking this app's notifications


I'm developing an android application with Java, Node.Js as backend and Postgres as database. The application for now has an authentication and I have implemented the recognition of user activity through the related API. My problem however, is that the notifications of the application result turned off and blocked in the device settings. I've tried both on different emulators and on my real device but there is no way to turn on the app notifications that are blocked.

blocked notifications

This is my manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:usesCleartextTraffic="true"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.MTS"
        >
        <service
            android:name=".ARServices.ActivityRecognitionService"
            android:exported="false" />
        <service
            android:name=".ARServices.ActivityRecognitionBackgroundService"
            android:enabled="true"
            android:exported="false" />
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:theme="@style/Theme.MTS">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".HomeActivity"
            android:exported="true"
            android:theme="@style/Theme.MTS">
        </activity>

        <service
            android:name=".ARServices.ActivityRecognitionService"
            android:exported="false" />
    </application>

</manifest>

How can I solve this problem? Any ideas?

Thanks in advance!


Solution

  • Try adding POST_NOTIFICATION permission to your manifest:

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

    and then going to the settings and allowing notification permission.

    That's good for experimenting, but as soon as you decide to go in production, you should handle permission requesting. This is a good video.