Я пытаюсь получать уведомления на свой мобильный телефон, используя реагировать родной. Но уведомлений недостаточно, уже настроен реактивный-firebase с помощью документации. веб-сайт firebase уже распознает приложение, а приложение уже имеет google-сервисы. Уведомление не приходит на мобильный, когда я отправляю через веб-сайт Firebase.
Я использую Google Переводчик, извините
Следит за кодами: Файл: android / buildGradle
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
}
dependencies {
classpath('com.android.tools.build:gradle:3.4.1')
classpath('com.google.gms:google-services:4.2.0')
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
android / app / buildGradle
dependencies {
//implementation project(':react-native-push-notification')
implementation project(':react-native-vector-icons')
implementation project(':react-native-fetch-blob')
implementation project(':react-native-webview')
implementation project(':react-native-image-picker')
implementation project(':react-native-firebase')
implementation project(':react-native-reanimated')
implementation project(':react-native-pdf')
//implementation project(':rn-fetch-blob')
implementation project(':react-native-gesture-handler')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation "com.facebook.react:react-native:+"
implementation "com.google.android.gms:play-services-base:16.1.0"
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation "com.google.firebase:firebase-messaging:19.0.0"
implementation 'com.google.firebase:firebase-analytics:17.0.0'
implementation 'me.leolin:ShortcutBadger:1.1.21@aar'}
apply plugin: 'com.google.gms.google-services'
´
manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.entremasons">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
<!-- < Only if you're using GCM or localNotificationSchedule() > -->
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
android:launchMode="singleTop">
<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" />
<service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>
</manifest>
MainAplication files contain the necessary imports and their list package calls
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
//new ReactNativePushNotificationPackage(),
new VectorIconsPackage(),
new RNFetchBlobPackage(),
new RNCWebViewPackage(),
new ImagePickerPackage(),
new RNFirebasePackage(),
new ReanimatedPackage(),
new RCTPdfView(),
new RNGestureHandlerPackage(),
new RNFirebaseMessagingPackage(),
new RNFirebaseNotificationsPackage(),
new RNFirebaseAnalyticsPackage()
);
}
`
app.js
subscribeToNotificationListeners() {
const channel = new firebase.notifications.Android.Channel(
'notification_channel_name', // To be Replaced as per use
'Notifications', // To be Replaced as per use
firebase.notifications.Android.Importance.Max
).setDescription('A Channel To manage the notifications related to Application');
firebase.notifications().android.createChannel(channel);
this.notificationListener = firebase.notifications().onNotification((notification) => {
console.log('onNotification notification-->', notification);
console.log('onNotification notification.data -->', notification.data);
console.log('onNotification notification.notification -->', notification.notification);
// Process your notification as required
this.displayNotification(notification)
});
´ остальное добавляется в app.js в настройках уведомлений дисплеяв компоненте монтировался компонент, а компонент wull moount открыл файлы, чтобы вам было легче их прочитать заранее.