Android从解析中接收重复推送通知

时间:2015-05-20 09:23:22

标签: android parse-platform ionic

我正在使用解析推送plugin,我的用户正在接收重复的推送通知。

我已经检查了解析推送仪表板,它说已发送一个,我的手机接收它为两个。

我创建了一个频道并订阅了该频道,推送通知在该频道中显示为重复。

我的application.java文件是

package com.ionicframework.xxx;

import android.app.Application;
import org.apache.cordova.*;
import com.parse.Parse;
import com.parse.ParseInstallation;

public class MainApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        Parse.initialize(this, "xxx", "xxx");
        ParseInstallation.getCurrentInstallation().saveInBackground();
    }
}

我的applicationmanifest文件是

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="20000" android:versionName="2.0.0" package="com.ionicframework.xxx" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:name="com.ionicframework.xxx.MainApplication" android:supportsRtl="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <data android:scheme="leadership" />
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
            </intent-filter>
        </activity>
        <receiver android:exported="false" android:name="com.parse.ParsePushBroadcastReceiver">
            <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>
        <service android:name="com.parse.PushService" />
        <receiver android:exported="false" android:name="com.phonegap.plugins.ParsePushPluginReceiver">
            <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="com.ionicframework.xxx" />
            </intent-filter>
        </receiver>
        <receiver android:name="com.parse.ParseBroadcastReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.USER_PRESENT" />
            </intent-filter>
        </receiver>
    </application>
    <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="21" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <permission android:name="com.ionicframework.xxx.permission.C2D_MESSAGE" android:protectionLevel="signature" />
    <uses-permission android:name="com.ionicframework.xxx.permission.C2D_MESSAGE" />
</manifest>

然后我的app.js离子

app1.run(function($ionicPlatform, $location, $rootScope) {
  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if(window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }
      ParsePushPlugin.register({eventKey:"myEventKey"}, //will trigger receivePN[pnObj.myEventKey]
          function() {
              console.log("registered devise")
          }, function(e) {
              console.log('error registring devise')
          });

      ParsePushPlugin.subscribe('TestChanel', function(msg) {
          console.log("Subscribed")
      }, function(e) {
          console.log("error subscribing")
      });

  });
})

1 个答案:

答案 0 :(得分:-1)

这已于7月1日修复。请参阅此处的更改日志their download page