ern*_*neo 21 android push-notification devicetoken parse-platform google-cloud-messaging
这是Parse控制台上我的安装页面中的情况:

如您所见,某些设备具有"deviceToken",而某些设备没有"deviceToken".这并不好,因为每个设备都应该有deviceToken才能工作.
这怎么可能?这是一个严重的问题,因为那些没有deviceToken的人不会收到推送通知!
我已经按照Parse.com上的所有说明进行操作,即使在他们的空白项目的帮助下,也可以在网络上的各种问题的帮助下实现他们所说的一切.但没有解决我的问题,现在我无能为力.
我唯一能想到的是,在我的应用程序(它已经在商店中)之前用于使用Google Cloud Messaging,然后使用这个新的更新,我决定更改系统并使用Parse删除完全GCM系统.这两个系统之间是否存在冲突?
我需要解决这个问题,因为你可以想象这是一个严重的错误,现在我的3/4用户都没有收到推送通知.
如果你下载应用程序并安装它:一切都很好,deviceToken是好的.如果您更新应用程序,因为设备上已存在GCM版本:
对于没有deviceToken的设备,我尝试了很多东西:手动插入deviceToken,卸载并重新安装应用程序,删除Parse上的特定行等.但没什么好...仍然面临这个问题.
我的代码
Application.java
public class Application extends android.app.Application {
public Application() {
}
@Override
public void onCreate() {
super.onCreate();
// Initialize the Parse SDK.
Parse.initialize(this, "x", "x");
// Specify an Activity to handle all pushes by default.
PushService.setDefaultPushCallback(this, MainActivity.class);
}
Run Code Online (Sandbox Code Playgroud)
}
MainActivity.java 在我的mainActivity中,我只是将deviceToken(在我的情况下是installId)连接到我的userAgent:这工作正常:我总是有installId没有任何问题!这是我在MainActivity中唯一做的事情(我还需要做其他事吗?saveInBackground,callback等......?)
deviceToken = ParseInstallation.getCurrentInstallation().getInstallationId();
webSettings.setUserAgentString(userAgent + " ||" + deviceToken);
Run Code Online (Sandbox Code Playgroud)
AndroidManifest.xml中
<!-- Gestione del guasto-->
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!-- Utilizzo di internet -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Permesso di vibrare per le push notifications -->
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<!-- Mantiene attivo il processore così da poter ricevere in qualsiasi momento le notifiche -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- Consente di impostare l'allarme per l'aggiornamento automatico -->
<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>
<permission android:name="com.hoxell.hoxellbrowser.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.hoxell.hoxellbrowser.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<application
android:name="com.hoxell.hoxellbrowser.Application"
android:allowBackup="true"
android:icon="@drawable/ic_launcher_hoxell"
android:label="@string/app_name"
android:theme="@style/AppTheme"
>
<!-- Richiesto per le applicazioni che usano Google Play Services -->
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SettingsActivity"></activity>
<receiver android:name=".AlarmReceiver"/>
<service android:name="com.parse.PushService" />
<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>
<receiver android:name="com.hoxell.hoxellbrowser.Receiver"
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="com.hoxell.hoxellbrowser" />
</intent-filter>
</receiver>
</application>
Run Code Online (Sandbox Code Playgroud)
的build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile 'com.android.support:support-v4:20.+' //support
compile "com.google.android.gms:play-services:5.0.+" //play services
compile 'com.parse.bolts:bolts-android:1.+'
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
Run Code Online (Sandbox Code Playgroud)
}
我真的不知道还能做什么,这就是为什么我希望有人可以帮助我.
谢谢.
您是否在平板电脑上同时使用2个用户配置文件?因为我有完全相同的问题,根据我的经验,配置文件之间存在冲突.事实上,在我的情况下,一个设备正在向Parse数据库注册2行.一个是deviceToken,一个是"未定义"的deviceToken.
不幸的是我从来没有解决过这个问题,我想这是Parse的一个错误.
| 归档时间: |
|
| 查看次数: |
9639 次 |
| 最近记录: |