PARSE:推送通知" deviceToken"未定义未定义、通知、PARSE、deviceToken

2023-09-06 03:20:28 作者:一夕半夏

这是在解析控制台我安装页面的情况:

This is the situation in my Installation page on Parse Console:

正如你所看到的一些设备具有deviceToken,有的不具备deviceToken。 这是不好的,因为每个设备应该有deviceToken才能工作。

As you see some devices have the "deviceToken" and some do not have the "deviceToken". This is not good because every device should have the deviceToken in order to work.

这怎么可能呢?这是一个严重的问题,因为那些没有deviceToken 没有收到推送通知!

How is this possible? This is a serious problem because the ones that do not have the deviceToken do not receive push notifications!

我跟着上Parse.com所有的指令和实现的事情,因为他们说,即使他们的空白项目的帮助,并与在网络上的各种问题的帮助。但是,没有什么固定我的问题,现在我什么都做不了。

I've followed all the instructions on Parse.com and implemented everything as they said, even with the help of their blank project and with the help of various questions on the web. But nothing fixed my problem and now I can't do anything.

我唯一能想到的是,我的应用程序之前,(这是已经在商店)来使用谷歌云消息传递,然后用这个新的更新,我决定改变系统并使用解析删除完全GCM系统。有没有可能在两个系统之间的冲突?

The only thing I can think about is that before my application (it is already on the Store) used to use Google Cloud Messaging and then with this new update I've decided to change the system and use Parse removing completely GCM system. Is there maybe a conflict between the two systems?

我要解决这个问题,你可以想像,这是一个严重的错误,现在3/4的我的用户不会收到推送通知。

I need to fix this as you can imagine this is a serious bug and now 3/4 of my users do not receive push notifications.

如果你下载的应用程序,并安装它:一切都是美好的,在deviceToken是确定的。如果您更新应用程序,因为已经有了另外一个版本GCM设备上:

If you download the app and install it: everything is good, the deviceToken is ok. If you update the app because there already was a version with GCM on the device:

在一些设备在注册解析很好,没有任何问题 在一些设备在注册解析,但没有的deviceToken some devices register in Parse good, without any problem some devices register in Parse but without the deviceToken

对于不具备deviceToken设备我已经尝试了很多东西:手动插入deviceToken,卸载和重新安装应用程序,删除解析等具体行,但没有什么好...还面临着这样的问题。

For the devices that do not have the deviceToken I've tried a lot of things: inserting a deviceToken manually, uninstall and reinstall the application, delete the specific row on Parse, etc. But nothing good... Still facing this problem.

我的code 的

MY CODE

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);

}

}

MainActivity.java 在我mainActivity我只是串联的deviceToken(在我的情况下,它是installationId)到我的userAgent:这做工精细:我一直有installationId没有任何问题!这是我做我的MainActivity的唯一的事情(做我需要做什么吗?saveInBackground,回调等。?)

MainActivity.java In my mainActivity I just concatenate the deviceToken (in my case it is the installationId) into my userAgent: and this work fine: I always have the installationId without any problem! And this is the only thing I am doing in my MainActivity (do I need to do anything else? saveInBackground, callback, etc..?)

deviceToken = ParseInstallation.getCurrentInstallation().getInstallationId();
webSettings.setUserAgentString(userAgent + " ||" + deviceToken);

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>

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')

}

我真的不知道自己还能做什么,这就是为什么我希望有人能帮助我。

I don't really know what else to do, that's why I hope that somebody can help me with this.

谢谢你。

推荐答案

您在同一时间在平板电脑上使用2的用户配置文件?因为我有完全相同的问题,并从我的经验,还有就是配置文件之间的冲突。逸岸,在我的情况一台设备被登记2行到解析数据库。一个具有deviceToken和一个用未定义deviceToken

Are you using 2 user profiles at the same time on the tablet? Because I've had exactly the same problem and from my experience there is a conflict between the profiles. Infact, in my situation one device was registering 2 rows into the Parse database. One with the deviceToken and one with "undefined" deviceToken.

不幸的是我从来没有解决这个问题,我想这是从解析错误。

Unfortunately I've never solved this problem, I guess this is a bug from Parse.