Я использую парсинг push-уведомлений с это изображение докера .
после того, как сервер конфигурации и панель мониторинга отправляют объект с curl.но я запутался, как с помощью этого сервера отправлять push-уведомления на устройства Android!на моем сервере у меня не может быть подключение к интернету все время, и мой вопрос fcm не является обязательным для отправки push?или это единственный способ получать push-сообщения от устройств Android от сервера синтаксического анализа?
после запуска моего приложения с приведенными ниже кодами, запись об установке сохраняется, и я вижу это на панели анализа.но при отправке push android устройство не получает push.нужно ли parse подключать сервер разбора к Firebase?(если да, как можно настроить интеграцию fcm с синтаксическим анализом) (если нет, как настроить сервер синтаксического анализа или приложение для Android для получения push-сообщений?)
вот моя реализация:
(Google-services.json добавлен в каталог приложения)
build.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.test.project"
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "1"
multiDexEnabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.1'
implementation 'androidx.multidex:multidex:2.0.1'
implementation "com.github.parse-community.Parse-SDK-Android:fcm:1.20.0"
implementation "com.github.parse-community.Parse-SDK-Android:parse:1.20.0"
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.google.firebase:firebase-messaging:18.0.0'
}
Класс приложения:
OkHttpClient.Builder builder = new OkHttpClient.Builder();
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
builder.networkInterceptors().add(httpLoggingInterceptor);
Parse.initialize(new Parse.Configuration.Builder(this)
.applicationId("APP_ID")
.enableLocalDataStore()
.server("http://ServerIp:1337/parse/")
.clientBuilder(builder)
.build()
);
Parse.setLogLevel(Parse.LOG_LEVEL_DEBUG);
ParsePush.subscribeInBackground("channel1", new SaveCallback() {
@Override
public void done(ParseException e) {
Log.e(LOG_TAG, "Successfully subscribed to Parse!");
}
});
ParseInstallation.getCurrentInstallation().saveInBackground();
Манифест служб и получателей:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.test.project">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission
android:name="ir.meedc.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="ir.meedc.permission.C2D_MESSAGE" />
<application
android:name=".App"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:supportsRtl="false"
android:usesCleartextTraffic="true">
<receiver
android:name=".service.parsePush"
android:exported="false">
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
<receiver
android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="info.androidhive.parsenotifications" />
</intent-filter>
</receiver>-->
<service
android:name="com.parse.fcm.ParseFirebaseInstanceIdService"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<service android:name="com.parse.fcm.ParseFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<receiver
android:name="com.parse.ParsePushBroadcastReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
<receiver
android:name="com.parse.ParsePushBroadcastReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
<activity
android:name=".ActivityMain"
android:configChanges="orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustNothing">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</manifest>
Установочная запись сохранена.
![installation record on dashboard](https://i.stack.imgur.com/tFsJx.png)
некоторые толчки, которые отправляются с приборной панели или API с curl.
![sent pushes](https://i.stack.imgur.com/sQGyW.png)
(решено) наконец я выясняю, можно ли передать конфигурацию команде инициализации parse-server.просто нужно создать файл и передать его команде parse-server.