简体   繁体   中英

Parse push notifications without gcm

I was implementing Parse push notifications in my project but, due to legal issues, I'm not able to install Google play services, so the broadcast receiver used to receive notifications is the ParsePushBroadcastReceiver, not the GcmBroadcastReceiver. Firstly I have tried with this code in the manifest:

<service android:name="com.parse.PushService" />
<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>

Then, I have tried with this one:

<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParsePushBroadcastReceiver"
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="com.parse.starter" />
  </intent-filter>
</receiver>

As a result, the device have been registered with not pushType and deviceToken, showing the text (undefined) in both fields. When I try to send a push to all the registered devices, Parse throw an error such as: 解析推送错误

But the installations are currently active. Can anyone help me?

Thanks in advance.

You miss the parse application id and client key (you will find these values on your parse dashboard)

<application
    ...>
    [...]

    <meta-data
        android:name="com.parse.APPLICATION_ID"
        android:value="xxxxxxxxxxxxxxx" />
    <meta-data
        android:name="com.parse.CLIENT_KEY"
        android:value="yyyyyyyyyyyyyyy" />

    [...]
</application>

and also inside the receiver:

<category android:name="com.parse.starter" />

should be:

<category android:name="you.package.name" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM