无法从解析服务器发送通知

时间:2019-02-15 16:16:40

标签: android firebase push-notification parse-server

我正在尝试从托管在AWS上的Bitnami Parse Server(3.1.2)发送推送通知。 我在server.js中有来自Firebase的服务器密钥和发件人ID。 通知可从firebase控制台运行,但不能从解析服务器(既不能从dashbord也不能从REST API)工作。它说它已保存,但是即使有两个安装,“已发送的推送”仍显示为0。

有什么想法吗?

已发送邮件0

Puhes Sent 0

我的清单:

<?xml version="1.0" encoding="utf-8"?>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />


<uses-permission android:name="com.parse.starter.permission.C2D_MESSAGE" />
<application
    android:name=".StarterApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme">
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".DepListActivity" />
    <activity android:name=".AngListActivity" />
    <activity android:name=".ChangeThePin" />
    <activity android:name=".PicActivity" />
    <activity android:name=".AddDepActivity" />
    <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>  


</application>

项目摇篮:

buildscript {
    repositories {
        jcenter()
        mavenCentral()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'
        classpath 'com.google.gms:google-services:4.2.0' // google-services plugin
    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        google()
        maven { url "https://jitpack.io" }
    }
}

ext {
    compileSdkVersion = 24
    buildToolsVersion = "24.0.1"

    minSdkVersion = 17
    targetSdkVersion = 24
}

模块gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.parse.starter"
        minSdkVersion 26
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
    implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
    implementation 'com.parse.bolts:bolts-tasks:1.3.0'

    implementation 'com.github.parse-community.Parse-SDK-Android:fcm:1.19.0'
    implementation 'com.github.parse-community.Parse-SDK-Android:parse:1.19.0'
    implementation 'com.google.firebase:firebase-core:16.0.7'
    implementation 'com.google.firebase:firebase-messaging:17.3.4'

    implementation 'com.google.android.gms:play-services-auth:16.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
}
apply plugin: 'com.google.gms.google-services'

和server.js

var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var app = express();
// Specify the connection string for your mongodb database
// and the location to your Parse cloud code
var api = new ParseServer({
    databaseURI: "",
    cloud: "./node_modules/parse-server/lib/cloud-code/Parse.Cloud.js",
    appId: "",
    masterKey: "",
    push: {
    android: {
      senderId: "",
      apiKey: ""
    }
  },
    fileKey: "",
    serverURL: ""
});
// Serve the Parse API on the /parse URL prefix
app.use('/parse', api);

var port = 1337;
app.listen(port, function() {
    console.log('parse-server running on port ' + port);
});

//Parse Dashboard
var ParseDashboard = require('parse-dashboard');
var dashboard = new ParseDashboard({
    apps: [
        {
            appName: "My Bitnami Parse API",
            appId: "",
            masterKey: "",
    push: {
    android: {
        senderId: "",
        apiKey: ""
    }
  },
            fileKey: "",
            production: true,
            serverURL: "
        }
    ],
    users: [
        {
            user: "user",
            pass: ""
        }
    ], useEncryptedPasswords: true
});

var allowInsecureHTTP = true;

// Serve the Parse Dashboard on the /parsedashboard URL prefix
app.use('/', dashboard);

var portdash = 4040;
app.listen(portdash, function() {
    console.log('parse-dashboard running on port ' + portdash);
});

0 个答案:

没有答案