Воспроизведение собственного звука push-уведомлений на Android O - PullRequest
0 голосов
/ 11 декабря 2018

Я сталкиваюсь с проблемами при воспроизведении пользовательского звука в приложении RN с Android O и выше.

Когда targetSdkVersion было 23, все работало просто отлично, так как увеличение до 26 не будет работать на Oreoи выше.

Чтобы увидеть, что происходит, я добавил журнал в RNPushNotificationHelper.java после notification.build(): Log.i(LOG_TAG, "Info: " + info)

На Android 7 он показывает:

12-11 11:07:14.466  9084  9345 I RNPushNotification: Info: Notification(pri=1 contentView=null vibrate=[0,300] sound=android.resource://br.com.getrak.gconnect/2131427328 defaults=0x4 flags=0x10 color=0xffff6600 category=call vis=PRIVATE)

На Android O это показывает:

12-11 11:27:59.444 32608 32655 I RNPushNotification: Info: Notification(channel=rn-push-notification-channel-id pri=1 contentView=null vibrate=null sound=null defaults=0x4 flags=0x10 color=0xffff6600 category=call vis=PRIVATE)

Я настроил канал на AndroidManifest.xml, и моя конфигурация похожа на примеры.

  • реакция: ^ 16.5.1
  • реакция-нативная: 0.57.0
  • реакция-нативная-push-уведомление: ^ 3.1.2

build.gradle:

ext {
    buildToolsVersion = "27.0.3"
    minSdkVersion = 21
    compileSdkVersion = 26
    targetSdkVersion = 26
    supportLibVersion = "26.1.0"

    googlePlayServicesVersion = "+"
}

Android Manifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com;.xxx.myapp">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
      android:name=".MainApplication"
      android:allowBackup="true"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:theme="@style/AppTheme">

        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_name"
            android:value="MyApp"/>
        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_description"
            android:value="MyApp Alerts"/>

        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="adjustResize"
            android:launchMode="singleInstance">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />

        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>
        <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService" />
        <service
            android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
    </application>

</manifest>

Чего мне не хватает?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...