I want to implement push notification in my apps.
I can get the notification in my device. But I get some error message.
02-23 15:33:31.904 17918-17918/com.radaee.reader E/FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforcement<> 02-23 15:33:31.904 17918-17918/com.radaee.reader E/FirebaseInstanceId: Error while delivering the message: ServiceIntent not found.
02-23 15:33:31.904 17918-22512/com.radaee.reader W/Bundle: Key google.sent_time expected String but value was a java.lang.Long. The default value was returned.
--------- beginning of /dev/log/system
02-23 15:33:31.914 17918-22512/com.radaee.reader W/Bundle: Attempt to cast generated internal exception:
java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
at android.os.Bundle.getString(Bundle.java:1121)
at com.google.android.gms.gcm.zza.zzae(Unknown Source)
at com.google.android.gms.gcm.GcmListenerService.zzo(Unknown Source)
at com.google.android.gms.gcm.GcmListenerService.zzn(Unknown Source)
at com.google.android.gms.gcm.GcmListenerService.zzm(Unknown Source)
at com.google.android.gms.gcm.GcmListenerService.zza(Unknown Source)
at com.google.android.gms.gcm.GcmListenerService$1.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
02-23 15:33:31.914 17918-22512/com.radaee.reader D/MyGcmListenerService: onMessageReceived
02-23 15:33:31.914 17918-22512/com.radaee.reader D/MyGcmListenerService: From: 631033776588
02-23 15:33:31.914 17918-22512/com.radaee.reader D/MyGcmListenerService: Message: Bundle[{google.sent_time=1487835190910, key1=testtesttest, key2=message2, type=notification, google.message_id=0:1487835190917734%768342b8768342b8, notification=Bundle[{body=432432, icon=ic_launcher, title=PDF Upload}], collapse_key=com.radaee.reader}]
02-23 15:33:31.914 17918-22512/com.radaee.reader D/MyGcmListenerService: type: notification
02-23 15:33:31.914 17918-22512/com.radaee.reader D/MyGcmListenerService: show notification
AndroidManifest.xml
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="com.push.test.permission.C2D_MESSAGE" />
<permission android:name="com.push.test.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<supports-screens android:largeScreens="true" android:anyDensity="true" android:normalScreens="true" android:smallScreens="true" android:resizeable="true" android:xlargeScreens="true"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.radaee.reader.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- [START gcm_receiver] -->
<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" />
<category android:name="com.radaee.reader" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.radaee.reader" />
</intent-filter>
</receiver>
<service
android:name="com.radaee.reader.MyGcmListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name="com.radaee.reader.MyInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
<service
android:name="com.radaee.reader.RegistrationIntentService"
android:exported="false">
</service>
</application><uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="com.push.test.permission.C2D_MESSAGE" />
<permission android:name="com.push.test.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<supports-screens android:largeScreens="true" android:anyDensity="true" android:normalScreens="true" android:smallScreens="true" android:resizeable="true" android:xlargeScreens="true"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.radaee.reader.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- [START gcm_receiver] -->
<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" />
<category android:name="com.radaee.reader" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.radaee.reader" />
</intent-filter>
</receiver>
<service
android:name="com.radaee.reader.MyGcmListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name="com.radaee.reader.MyInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
<service
android:name="com.radaee.reader.RegistrationIntentService"
android:exported="false">
</service>
</application>
Thanks for help!!
String and Long are completely different types you cannot cast them java.lang.ClassCastException: java.lang.Long cannot be cast to to java.lang.String
Hope this helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.