Push Notification Issues

0 votes

First of all thanks to you guys providing such a good platform for Android Application. As, I am using your push notification services in my Android App. Now, I want some specific changes for my app.

My main requirement is when notification is recieved by any user than he just click on to it. I need that notification message should open in my app.
But, Right now what happening is when user clicks on notification to see it. It normally opens the app but that notification doesnt comes in to the app.

And Secondly, I want to store those notifications in that app for a user. As well as how to send Images in the Notification.

If possible could you please send me any Sample Activity for the same. So, that i should use that code in my App. 
Please help for this.

Thanks.

Regards 

Prabhjas Singh

asked May 27, 2015 in App42 Cloud API-BaaS by prabhjassinghbajwa (25 points)

1 Answer

0 votes
 
Best answer

Hi Prabhjas,

As per our previous discusion is concern you have to pass message in notification Intent and have to retrieve it in onStart() method of that Activity. Now you are able to message to user.

If you want to implement Image Push as well that you can download our Rich Push Widget. It will show how can you send Push Notification messsage in following formats:

  • HTML
  • Text
  • Image
  • Video
  • YouTube

For storing Push messages you can use SharedPrefences or SQLLite Databse of android and retrieve all message when required.

Let me know if further help is concern.

Thanks

Vishnu

 

 

answered May 27, 2015 by Vishnu Garg (674 points)
selected May 27, 2015 by prabhjassinghbajwa
I am trying with the same which you explained me. But not able to make my App work on these things.
I want that my notification message should get open in my Android App.
Could you please help me with my code. If i mail you.
Thanks.
Yes, you can share your source with me I will check what problem you are facing in sending message in intent when application is opened by notification click.
Thanks a lot.
I mailed you mine Package. You can check. Right now i am receiving notifications in my app.But, I just want to open those notifications in my Android App and save it for a user.
You are using Old sample we have updated it with new Google GCM API. I have already revert on mail.
Yes, I am integrating that code in to my app and let you know whether it works or not.
Please remove old GCM.jar file and import google play service library in your Eclispe and add it as a library.
I have just shared my full application with you. Please check it out and update it.
Thanks a lot.
I have added the source and already shared with you, can you please replace it in your project and also add google_play_service as a library project. Please do that stuff first than I am going to help you out. You can find google_play_service library project "sdk\extras\google\google_play_services\libproject" here in your SDK location.
Yes! done with all those steps now.
So Now share the problem you are facing.
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.gcm.GoogleCloudMessaging;

import problem in App42GCMController.java and App42GCMService.java file.

Sending you screenshot on your email.
Hye Vishnu!

As you tried me help out very much. Thanks for that.
But really sorry to say that i have searched on net as well as tried using a code from your GitHub as well but they doesn't seems to work.
I request you please check this attachment i have attached all required folders.

Regards,
Prabhjas Singh
Yup! I have resolved all of the import errors and now let me use it. If it works for me.
After fixing all those problems application is getting forcibly closed.
05-28 06:48:19.591: E/Trace(696): error opening trace file: No such file or directory (2)
05-28 06:48:20.481: I/System.out(696): Installation.getSession : /data/data/com.prabhjas.sikhsangatnz/files/SESSION: open failed: ENOENT (No such file or directory)
05-28 06:48:20.481: I/System.out(696): Installation.getUser : /data/data/com.prabhjas.sikhsangatnz/files/USER: open failed: ENOENT (No such file or directory)
05-28 06:48:20.521: I/dalvikvm(696): Could not find method com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable, referenced from method com.shephertz.app42.push.plugin.App42GCMController.isPlayServiceAvailable
05-28 06:48:20.551: W/dalvikvm(696): VFY: unable to resolve static method 132: Lcom/google/android/gms/common/GooglePlayServicesUtil;.isGooglePlayServicesAvailable (Landroid/content/Context;)I
05-28 06:48:20.551: D/dalvikvm(696): VFY: replacing opcode 0x71 at 0x0000
05-28 06:48:20.551: I/dalvikvm(696): Could not find method com.google.android.gms.gcm.GoogleCloudMessaging.getInstance, referenced from method com.shephertz.app42.push.plugin.App42GCMController.registerOnGCM
05-28 06:48:20.551: W/dalvikvm(696): VFY: unable to resolve static method 134: Lcom/google/android/gms/gcm/GoogleCloudMessaging;.getInstance (Landroid/content/Context;)Lcom/google/android/gms/gcm/GoogleCloudMessaging;
05-28 06:48:20.551: D/dalvikvm(696): VFY: replacing opcode 0x71 at 0x0000
05-28 06:48:20.561: W/dalvikvm(696): VFY: unable to find class referenced in signature (Lcom/google/android/gms/gcm/GoogleCloudMessaging;)
05-28 06:48:20.561: W/dalvikvm(696): VFY: unable to find class referenced in signature (Lcom/google/android/gms/gcm/GoogleCloudMessaging;)
05-28 06:48:20.572: D/AndroidRuntime(696): Shutting down VM
05-28 06:48:20.591: I/System.out(696):  Json String : {"app42":{"event":{"superProperties":{"app42_os_version":"4.1.2","app42_installAt":"","app42_lastCommunicatedAt":"","app42_model":"sdk","app42_carrier":"Android","app42_screen_width":768,"app42_counter":1,"app42_screen_height":1184,"app42_brand":"generic","app42_lib_version":"1.0","app42_app_version":"2.0","app42_screen_dpi":320,"app42_os":"Android"},"userProperties":{},"app42_userUpdatedOn":"","eventName":"INSTALL","installProperties":{},"app42_lastCommunicatedAt":""}}}
05-28 06:48:20.591: W/dalvikvm(696): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
05-28 06:48:20.601: E/AndroidRuntime(696): FATAL EXCEPTION: main
05-28 06:48:20.601: E/AndroidRuntime(696): java.lang.NoClassDefFoundError: com.google.android.gms.common.GooglePlayServicesUtil
05-28 06:48:20.601: E/AndroidRuntime(696):     at com.shephertz.app42.push.plugin.App42GCMController.isPlayServiceAvailable(App42GCMController.java:45)
05-28 06:48:20.601: E/AndroidRuntime(696):     at com.prabhjas.sikhsangatnz.MainActivity.onStart(MainActivity.java:117)
05-28 06:48:20.601: E/AndroidRuntime(696):     at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163)
05-28 06:48:20.601: E/AndroidRuntime(696):     at android.app.Activity.performStart(Activity.java:5018)
05-28 06:48:20.601: E/AndroidRuntime(696):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032)
05-28 06:48:20.601: E/AndroidRuntime(696):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
05-28 06:48:20.601: E/AndroidRuntime(696):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
05-28 06:48:20.601: E/AndroidRuntime(696):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
05-28 06:48:20.601: E/AndroidRuntime(696):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-28 06:48:20.601: E/AndroidRuntime(696):     at android.os.Looper.loop(Looper.java:137)
05-28 06:48:20.601: E/AndroidRuntime(696):     at android.app.ActivityThread.main(ActivityThread.java:4745)
05-28 06:48:20.601: E/AndroidRuntime(696):     at java.lang.reflect.Method.invokeNative(Native Method)
05-28 06:48:20.601: E/AndroidRuntime(696):     at java.lang.reflect.Method.invoke(Method.java:511)
05-28 06:48:20.601: E/AndroidRuntime(696):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
05-28 06:48:20.601: E/AndroidRuntime(696):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
05-28 06:48:20.601: E/AndroidRuntime(696):     at dalvik.system.NativeStart.main(Native Method)
05-28 06:48:20.611: I/System.out(696): sortedparams: apiKeyfef20ead2cb03d5ed154d68a6410e260de98cca12a5ca0aaa542937571af85adbody{"app42":{"event":{"superProperties":{"app42_os_version":"4.1.2","app42_installAt":"","app42_lastCommunicatedAt":"","app42_model":"sdk","app42_carrier":"Android","app42_screen_width":768,"app42_counter":1,"app42_screen_height":1184,"app42_brand":"generic","app42_lib_version":"1.0","app42_app_version":"2.0","app42_screen_dpi":320,"app42_os":"Android"},"userProperties":{},"app42_userUpdatedOn":"","eventName":"INSTALL","installProperties":{},"app42_lastCommunicatedAt":""}}}timeStamp2015-05-28T01:18:20.543Zversion1.0
05-28 06:48:20.701: I/System.out(696): Post URL is https://analytics.shephertz.com/cloud/1.0/event?
05-28 06:48:20.701: I/System.out(696):  Setting Header value : SDKName : Android
05-28 06:48:20.731: I/System.out(696):  Setting Header value : timeStamp : 2015-05-28T01:18:20.543Z
05-28 06:48:20.731: I/System.out(696):  Setting Header value : loggedInUser : TestApp
05-28 06:48:20.731: I/System.out(696):  Setting Header value : signature : GXO7H8KKhZrrQ6fKEnT%2FAb2qgFE%3D
05-28 06:48:20.731: I/System.out(696):  Setting Header value : deviceId : c8384e82-641b-4ec8-8687-983df1f80213
05-28 06:48:20.731: I/System.out(696):  Setting Header value : apiKey : fef20ead2cb03d5ed154d68a6410e260de98cca12a5ca0aaa542937571af85ad
05-28 06:48:20.741: I/System.out(696):  Setting Header value : version : 1.0
05-28 06:48:20.951: D/dalvikvm(696): GC_CONCURRENT freed 243K, 3% free 10991K/11271K, paused 26ms+62ms, total 279ms
05-28 06:48:25.841: I/Process(696): Sending signal. PID: 696 SIG: 9
As I have mentioned earlier your google_play_library project must be in the same directory.
I understand and i have implemented the same also taken help from your tutorials and videos as well.I have taken your lots of time as well for the same. But i would like to request you that i am sharing my android application with you and if possible please help me to make changes in it. As, I need it very urgently for some purpose.
https://cldup.com/zQKIqFsoVK.zip
Download it from here.
So, kindly request you.
Thanks a lot.
I have already tested on my end your project and its working fine as you mentioned logs like :
java.lang.NoClassDefFoundError: com.google.android.gms.common.GooglePlayServicesUtil

that will occurs run time when your library and your projects directories are not same.
As you seen my whole project can you tell me specific steps where it is required to make those changes because i added those libraries each and every place where you told me.
My means in same drive like d: and e: not in same project directory.You have paste it in project directory please place it outside the project but in the same drive.Let me know if it not works.
Is it possible for you to share that whole project which was working with you so that i should directly import it in Eclipse.
DropBox link again its working fine
https://www.dropbox.com/s/vjkcrcrwddv153c/prafas.zip?dl=0
First of all thanks for providing me files. I tried installing its .apk in my mobile but its not getting installed.
It says App not installed.
It depends on your Manifest.xml file, remove action from MainActivity.java file to launch the application.
    <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />

One more thing I want to add whatever code you are writing you must have a knowledge about that code.
Thanks, App is working the one which you shared with me but while sending push messages they are not getting opened in that application.
Thanks a lot. I have made it working. Now just implementing how to send images as a push notification through my shephertz account as i couldn't see any option over there.
How to save these push notifications in the app?
You can save the notification message when they received your side using:
1. Shared Preferences
2. SQLite database
3. Save them in file
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...