GCM 和 Parse 冲突
GCM and Parse conflict
我在 AndroidManifest
中有以下内容。我需要从我的网络服务和 Parse 发送推送通知。问题是,如果我 运行 如下所示的应用程序,来自我的 WS
(网络服务)的推送将会通过,但来自 Parse
的推送不会。
如果我注释掉 GCM 部分,Parse 将起作用。
我还注意到,在 Parse table 中,当两者都启用时,在 deviceToken
列下,Parse 会添加一个 |ID||1|
前缀到 deviceToken
.如果我注释掉 GCM 部分,Parse 将不会将该前缀添加到 deviceToken
。我不确定这是否重要...
知道我做错了什么吗?我需要支持这两种功能,但似乎有些东西与其他东西冲突。有什么想法吗?
如果您需要更多源代码,请告诉我...
<!-- ================================= GCM ================================= -->
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
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.moc.sif" />
</intent-filter>
</receiver>
<service
android:name=".pushnotif.gcm.GCMListener"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name=".pushnotif.gcm.GCMInstanceIdListener"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID" />
</intent-filter>
</service>
<service
android:name=".pushnotif.gcm.GCMRegistrationIntentService"
android:exported="false">
</service>
<!-- ================================= PARSE ================================= -->
<service android:name="com.parse.PushService" />
<receiver
android:name=".pushnotif.parse.receivers.ParsePushReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
<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.moc.sif" />
</intent-filter>
</receiver>
看来我已经修好了。
问题是初始化 Parse 之后我调用了这个方法:
InstanceID instanceID = InstanceID.getInstance(getApplicationContext());
String token = instanceID.getToken(getString(R.string.gcm_sender_id), GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
这显然使 Parse 覆盖了 table 中的 deviceToken
。我正在使用上面的 token
发送到我的网络服务。我为解决它所做的是注释掉上面两行并使用 Parse 生成的 deviceToken
代替。因此,Parse 和我的网络服务都收到了从 Parse 库中获得的相同 deviceToken
。现在都可以工作了...
这应该由 Parse 团队解决。不幸的是,在我的情况下,其他第三个库也获得了令牌,并且无法修复它。 Parse 还会阻止 "deviceToken" 字段,因此我无法更新它以更正一个字段。
我在 AndroidManifest
中有以下内容。我需要从我的网络服务和 Parse 发送推送通知。问题是,如果我 运行 如下所示的应用程序,来自我的 WS
(网络服务)的推送将会通过,但来自 Parse
的推送不会。
如果我注释掉 GCM 部分,Parse 将起作用。
我还注意到,在 Parse table 中,当两者都启用时,在 deviceToken
列下,Parse 会添加一个 |ID||1|
前缀到 deviceToken
.如果我注释掉 GCM 部分,Parse 将不会将该前缀添加到 deviceToken
。我不确定这是否重要...
知道我做错了什么吗?我需要支持这两种功能,但似乎有些东西与其他东西冲突。有什么想法吗?
如果您需要更多源代码,请告诉我...
<!-- ================================= GCM ================================= -->
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
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.moc.sif" />
</intent-filter>
</receiver>
<service
android:name=".pushnotif.gcm.GCMListener"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name=".pushnotif.gcm.GCMInstanceIdListener"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID" />
</intent-filter>
</service>
<service
android:name=".pushnotif.gcm.GCMRegistrationIntentService"
android:exported="false">
</service>
<!-- ================================= PARSE ================================= -->
<service android:name="com.parse.PushService" />
<receiver
android:name=".pushnotif.parse.receivers.ParsePushReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
<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.moc.sif" />
</intent-filter>
</receiver>
看来我已经修好了。
问题是初始化 Parse 之后我调用了这个方法:
InstanceID instanceID = InstanceID.getInstance(getApplicationContext());
String token = instanceID.getToken(getString(R.string.gcm_sender_id), GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
这显然使 Parse 覆盖了 table 中的 deviceToken
。我正在使用上面的 token
发送到我的网络服务。我为解决它所做的是注释掉上面两行并使用 Parse 生成的 deviceToken
代替。因此,Parse 和我的网络服务都收到了从 Parse 库中获得的相同 deviceToken
。现在都可以工作了...
这应该由 Parse 团队解决。不幸的是,在我的情况下,其他第三个库也获得了令牌,并且无法修复它。 Parse 还会阻止 "deviceToken" 字段,因此我无法更新它以更正一个字段。