2

Error : Device token Field always null in Parse Installation table.

code

java

ParseInstallation.getCurrentInstallation().saveInBackground();
ParsePush.subscribeInBackground(AppConfig.PARSE_CHANNEL, new SaveCallback() {
        @Override
        public void done(ParseException e) {
            Log.e(TAG, "Successfully subscribed to Parse!");
        }
    });

Manifest

  <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dev.leapup" >

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<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" />

<!--
  IMPORTANT: Change "com.parse.tutorials.pushnotifications.permission.C2D_MESSAGE" in the lines below
  to match your app's package name + ".permission.C2D_MESSAGE".
-->
<permission android:protectionLevel="signature"
            android:name="com.dev.leapup.pushnotifications.permission.C2D_MESSAGE" />
<uses-permission android:name="com.dev.leapup.pushnotifications.permission.C2D_MESSAGE" />

<application
    android:name=".application.LeapUpApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"

    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"

        android:screenOrientation="portrait"
        android:configChanges="keyboardHidden|orientation|screenSize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <service
        android:name=".services.LeapUpService"
        android:exported="false" >
    </service>

    <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.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" />

            <!--
              IMPORTANT: Change "com.parse.tutorials.pushnotifications" to match your app's package name.
            -->
            <category android:name="com.dev.leapup.pushnotifications" />
        </intent-filter>
    </receiver>
    <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>
    <!-- replace @drawable/push_icon with your push icon identifier -->
    <meta-data android:name="com.parse.push.notification_icon" android:resource="@drawable/ic_launcher"/>
</application>

Interesting fact is if use same java code in another project it works, generate the devicetoken. what is the reason, not generating devicetoken for this project , manifest problem?? anything need to change manifest? please help me.

Jithish P N
  • 1,970
  • 3
  • 26
  • 39
  • have you tried adding `ParseInstallation.getDefault().saveInBackground()` just after Parse initialization? – akhy Aug 10 '15 at 06:41
  • ParseInstallation.getCurrentInstallation().saveInBackground(); added this line before subscribe, not after initialize. – Jithish P N Aug 10 '15 at 06:54

2 Answers2

1

your package name appears to be "com.dev.leapup" however you are incorrectly entering it as "com.dev.leapup.pushnotifications" in your manifest.

as per the comment from Parse

<!--
  IMPORTANT: Change "com.parse.tutorials.pushnotifications.permission.C2D_MESSAGE" in the lines below
  to match your app's package name + ".permission.C2D_MESSAGE".
-->
joneswah
  • 2,788
  • 3
  • 33
  • 32
0

You should install Google App for having device-token in your device... it helped me with old devices and genymotion emulator....

see tutorial on Github

see answer on StackOverFlow

Hope this will helps you and others...

Community
  • 1
  • 1
Ester Kaufman
  • 708
  • 10
  • 20