Ads

Monday, June 11, 2012

Appcelerator Cloud Push Notification in Android

This tutorial is based on Ti SDK 3.0.0, which is outdated. I have a new blog post based on Ti SDK 3.1.3GA using GCM.
What is Push Notification?
Push notification allows an app to notify you of new messages or events without the need to actually open the application, similar to how a text message will make a sound and pop up on your screen. This is a great way for apps to interact with us in the background, whether it be a game notifying us of some event occurring in our game world or simply the iPad's mail application beeping as a new message appears in our inbox. read more

Push Notification in Titanium Using Cloud Service
We can achieve Push Notification in Titanium using Appcelerator Cloud Service in 5 steps.
  1. Cloudpush Module Implementation
  2. Retrieve Device Token
  3. Cloud User Login
  4. Subscribe  a Channel
  5. Push Configuration
1)Cloudpush Module Implementation
Cloudpush provides methods for accessing Android push notifications from ACS using the MQTT protocol. require cloudpush in your app and add module in  your tiapp.xml

// add this line in tiapp.xml
<module platform="android">ti.cloudpush</module> 
// add this line in app.js
var CloudPush = require('ti.cloudpush'); 




2)Retrieve Device Token
You can Retrieve Device Token using below code
 
  CloudPush.retrieveDeviceToken({
          success: function deviceTokenSuccess(e) {
              alert('Device Token: ' + e.deviceToken);
              deviceToken = e.deviceToken
          },
          error: function deviceTokenError(e) {
              alert('Failed to register for push! ' + e.error);
       }
  });
 
3)Cloud User Login
Before subscribe for Push Notification, cloud user should logged in.
So create a test user in Appcelerator Cloud Console
My Apps -> Manage ACS ->  DEVELOPMENT ->  Users
and login with credential. Use below code for cloud user login

    Cloud.Users.login({
        login: 'push123',
        password: 'push123'
    }, function (e) {
        if (e.success) {
            alert("login success");
        } else {
            alert('Error: ' +((e.error && e.message) || JSON.stringify(e)));
        }
   });
4)Subscribe a Channel
Add following code for channel subscribtion

 
             Cloud.PushNotifications.subscribe({
                 channel: 'alert', // "alert" is channel name
                 device_token: deviceToken,
                 type: 'android'
             }, function (e){
                 if (e.success) {
                    alert('Subscribed for Push Notification!');
                 }else{
                     alert('Error:' +((e.error && e.message) || JSON.stringify(e)));
                 }
             });
 
5)Android Push Configuration
It is final step. In Appcelerator Cloud Console go to
My Apps -> Manage ACS -> DEVELOPMENT -> Settings/Android Push Configuration and enter the Application Package in the text box. Your pakage name should be similar to com.xxx.androidpush  Here xxx is company name and androidpush is Application name

Cool.., You have completed Android Push Notification setup(Here is the whole sample code). This time for testing, run the application in android device and click the button "Android Cloud Push Notification". You will get 3 alerts continuously.

Then go to My Apps -> Manage ACS -> DEVELOPMENT -> Push Notifications, here you can see "1 Android clients subscribed to push notifications"


It is time to send push notification, enter the values and hit the button "Send Push Notification" instantly you will receive notification in your Android device(with default icon and sound)

How to customize ACS Push notification?
Here you can use use your custom sounds and icons.

Icon

custom icons must be placed in below directory
App_root/platform/android/res/drawable/myicon.png 

Here "myicon.png" is custom icon, specified in the push message without the filename extension. For example: in icon text box enter the file name without extension(myicon)

Sound
Custom sound must be placed in below directory
app_root/platform/android/assets/sound/beep.wav 

Here "beep.wav" is custom sound, specified in the push message with the filename extension. For example: in custom sound text box you have to enter sound filename with extension(beep.wav). Here is the screens of custom notification

>

Here you can download the complete working project from my Github Appcelerator Titanium Android Push Notification

If anyone found difficulties in push notification implementation feel free to contact me

CodeStrong

103 comments:

  1. really appreciate your WORK ....

    ReplyDelete
  2. As a fan of your blog ..i must say that please remove the authenticating option for comments...

    ReplyDelete
  3. Thanks.
    By Following these steps I had successfully implemented ACS with android.

    ReplyDelete
  4. Best thanks for this tutorial ! But i have a force close when i pushed an alert normal ?

    ReplyDelete
    Replies
    1. Hi Nicolas, Thanks for reading my blog. Did you able to receive notification on your device?, When your app getting crashed(give me more info)?

      Delete
    2. Thanks for you answer, now have not problem. Thanks for your sharing, i add your blog to favorite ;)

      Delete
    3. Thanks Nicolas, You are Welcome

      Delete
  5. Thanks for this useful tutorial I have succeeded installing ACS with my android application for the first time but when i have uninstall the app and later i have installed it again i am not able anymore to receive notifications.
    So what i have to do to be able to receive notification if the user uninstall the app and then install it later.

    ReplyDelete
    Replies
    1. Hi Wael, Thanks for reading my blog. I too had the same issue while uninstall the App. But I dont have the solution for that one. Better you could ask in http://developer.appcelerator.com/

      Delete
    2. hi Karthi thanks for your reply , please if you had now the causing of the issue please post it asap, also me i will ask on appcelerator website and reply back to you if i found the problem

      Delete
  6. This comment has been removed by the author.

    ReplyDelete
  7. Hi! This post is very helpful to get my ACS push notification setup and ready.

    Here's the problem I faced: it shows "You currently have 1 iOS client, 1 Android client subscribed to push notifications." on my appcelerator account via my.appcelerator.com. However, when I send the push notification, only my that android device never receive it. (My iPhone is able to receive the pushes).

    Anybody got this problem as well?

    ReplyDelete
    Replies
    1. Hi Bryan, Thanks for reading my blog. Have you followed following steps for Android

      Titanium SDK 2.0.2
      Cloudpush Module Implementation (ti.cloudpush version 2.0.5)
      Retrieve Device Token
      Cloud User Login
      Push Configuration in ACS Console
      Subscribe a Channel

      Delete
    2. Hi Karthi! Thank you for your response!

      Yes, I've followed all the steps for android. On my.appcelerator.com, my ACS push notification registered the Android device that I have! Is there any other step that I might miss?

      Delete
    3. I've reached your step 5 and can see "1 Android clients subscribed to push notifications". But still, I can't see the notifications!

      Delete
    4. Hi Karthi, I found the source of the problem. I should not have followed the instructions in the https://cloud.appcelerator.com/docs/android#push first before following yours. I changed the AndroidManifest.xml when I should not!

      Many Karthi!

      Delete
  8. hi Karthy will the ACS work on the production environment correctly. and how to give access for the Admin Application to let him send notifications without the need of my help.

    ReplyDelete
    Replies
    1. Thanks for reading my blog.

      You can do this in two ways.

      1) Create a separate Appcelerator account for your client(Admin) and create a new app(use this cloud credential for your existing application). So that admin can send notification without your help.


      2) Build a web interface for admin using REST api (http://cloud.appcelerator.com/docs/api/v1/push_notifications/notify), which is provided by Appcelerator.

      Delete
  9. i have implemented the client successfully, thanks ... but im struggling with server side of it. Using js sdk from http://cloud.appcelerator.com/docs/api/v1/push_notifications/notify im getting 401 status code ... unauthorized/should be signed in

    ReplyDelete
    Replies
    1. Thanks for reading my blog.

      I think you haven't logged in with cloud user. To send the push notification,cloud user must be logged in.

      Delete
    2. Hi Thanks for the reply ... what do you exactly mean by "logging in with cloud user" ... as was logged into https://my.appcelerator.com/apps with the developer account .... and i have also created Users in app managment ...

      Delete
    3. Before subscribing for push notification, you need to login to app as a valid app user.

      Create a new user in ACS cloud console,then log in with the credential

      Refer the below Q&A

      http://developer.appcelerator.com/question/135727/acs-push-notifications-need-to-sign-in-error#answer-236704

      Delete
  10. Hi karthi...
    Thanks fr such an explantory post on android push using titanium...
    i have followed all the methods above....evn in the cloud i am gettin one android client registered but the notification not appearing on my device when i try to push it...
    is dere any access permissions it requires other dan the one alrdy present...

    ReplyDelete
    Replies
    1. Hi Jeff, Thanks for reading my blog.

      Can you tell me your Titanium sdk version and 'ti.cloudpush' module version

      Delete
    2. Titanium sdk ver. : 2.1.0.GA
      Android runtime : V8
      ti.cloudpush : 2.0.5
      ti.cloud : 2.1.0

      Delete
    3. Tryng to get this to work for the past 3 days with no luck....
      ure help would be much appreciated.. :)

      Delete
    4. Jeff,

      Have you followed all these steps,

      *Retrieve Device Token
      *Cloud User Login
      *Push Configuration in ACS Console
      *Subscribe a Channel

      If your answer is "Yes"

      Make sure whether you are in Development mode or Production mode(test push notification as per your mode selection)

      Best Luck :)

      Delete
    5. Hi these are the steps i followed..correct me if i made any mistake :)

      1. Created a new Titanium mobile project with cloud integration.

      AppName : pushtest
      AppId : com.push

      Titanium sdk ver. : 2.1.0.GA
      Android runtime : V8
      ti.cloudpush : 2.0.5
      ti.cloud : 2.1.0

      2. Added the following in Tiapp.xml

      ti.cloudpush

      3. Used the app.js provided by you. Changed the userId and passwrd to the created user.

      4. App-> Manage ACS -> DEV ->Access Control ->Create user
      5. App -> Settings -> Android Push Configuration -> com.push.pushtest
      6. Installed the App on Device(GalaxyS2)
      7. Clicked on "Register Buton" ->Got Device Token -> Login Success
      -> Subscribed for Push Notification
      8. DEV -> PushNotification -> Entered Alert and title ->Send Push Notification

      Inspite of following the above steps multiple times i was unable to obtain the notification on the device. :(

      I hope i havnt missed out anythn....
      Thnx...

      Delete
    6. Hi Jeff, Everything seems okay. Except below one.

      You have mentioned "com.push" as your app id in tiapp.xml, but in cloud console
      (App -> Settings -> Android Push Configuration -> com.push.pushtest)

      Here you have mentioned "com.push.pushtest" as your app id

      I suspect this may be an issue(am not sure). So make sure your app id is "com.push.pushtest" in your "tiapp.xml"


      Best Luck :)

      Delete
  11. Hi,
    First, thank you to share your work :)
    Im newbie on this, and i have question, where you get the module ti.cloudpush ?? i checked on the marketplace on appcelerator but nothing :(
    Have you a url or maybe its not free ?
    Thx

    ReplyDelete
    Replies
    1. Hi Thomas,

      "ti.cloudpush" is the inbuild module with titanium sdk (Titanium >2.0).

      "ti.cloudpush" is used for Android push notification. So you no need to download it separately. It comes along with your Titanium sdk.Just add require('ti.cloudpush'); in your code to use this module.

      Thanks for reading my blog.

      Delete
    2. Hi,
      first all, thx for answer me.
      It woks ! i mean , i have my device token, after im in step 3 and i created my user on my manage ACS, but i have error after compiled.
      You declare var cloudPush and its work fine but after for step 3 i have message reference Error, "cloud" is not defined. So i changed Cloud.Users by CloudPush.Users but i have a message error, users is not defined.

      Im sorry to disturb you :) can you help me ?

      Delete
    3. My fault,
      didn't integrate ti.cloud, sorry.

      Delete
    4. Hi again :)
      It works perfectly, thank you for answering fastly :)
      Last question, so if i wanna integrate this module to an application for android market.
      The best way is to call function defaultSubscribe directly in CloudPush.retrieveDeviceToken() in success ?
      It will add my client directly in my manage ACS ?

      Thk you again.
      ++ :)

      Delete
    5. Yes, you can. Follow the below order

      retrieveDeviceToken
      loginDefault
      defaultSubscribe

      Reference: https://github.com/railskarthi/acs_android_push/blob/master/Resources/app.js

      Delete
  12. Hi,
    it works fine on my simulator, and receive push perfectly.
    I wanted to install my test app on my device.
    When it launch, i've got error:
    Location [44,0] ti.cloud.js
    Message : Too deep recursion while parsing

    Any idea on this pls ?

    ReplyDelete
    Replies
    1. i copy and paste your code, and changed the default user, and charge on my device, i have the same error.

      Delete
    2. I resolved it when i put this line on my tiapp.xml
      32768

      ;)

      Delete
  13. Thank you for this tutorial. There are a few things that are not entirely clear to me so I hope you will be able to help.

    a. In the ACS control panel for the app in question under the Settings tab one of the required entries (Android) is Application Package. What does one enter here - the .apk file name or the application id, i.e com.example.app

    b. When one sends out a push progammatically it is easy to send out a notification where you specify the channel. However, it is not clear to me how I do this from the ACS control panel where the options offered are title, alert etc.

    ReplyDelete
    Replies
    1. Hi Atul, Thanks for reading my blog.

      a) you need to add your Application Id here(it should same as tiapp.xml)

      b)go to My Apps -> Manage ACS -> DEVELOPMENT -> Push Notifications, here you can find options like alert, title, badge...etc.
      Then hit the button "Send Push Notification" instantly you will receive notification.

      Best Luck :),
      Have a great day

      Delete
  14. Hi Karthi


    I have a few queries regarding titanium:


    1. Compared to Sencha Touch 2.0 how would you rate Titanium UI creation,look n feel...i am doing RnD on both technologies to choose one which suits my requiremnts and would like your opinion.


    For eg one of the req that is to display a nested tree list in one window which will display the child elements when i click on them as a collapsable view.


    2. Is UI designing on titanium a bit more complex since it uses the native controls than in sencha where we can use css to stylize the contrls.


    3. Can we use APN and Google cloud to send push notification to the device.
    If possible could u please provide with links.



    I have a req to create a hybrid application using either sencha touch/phonegap or titanium.
    Your advice would be highly appreciated.


    Thnks.

    ReplyDelete
  15. Hi Jeff, I haven't used Sencha Touch yet, without using I cant able to compare it with Titanium.

    You can use APN and Google cloud in Titanium to send push notification, here are few tutorials links

    Apn:
    http://iosmuncher.blogspot.in/2012/06/implementing-apns-in-titanium-start-to.html
    https://gist.github.com/1208144

    Android:
    https://github.com/Kuraturpa/titanium-c2dm

    ReplyDelete
  16. Hello



    For the sake of developing a server PHP program that sends push
    notification to the device, I tried in many ways to use ACS API described
    in this link:
    http://cloud.appcelerator.com/docs/api/v1/push_notifications/notify but I
    didn't succeed. By the way I was able to send push notifications manually
    through the ACS console.

    Could you help me with a sample program that proved to realize such a
    service ?

    Thanks in advance

    ReplyDelete
  17. Hi,
    It was good tutorial for push notification implementation.But I have done all the steps told by you(in appcelerator site as well as steps like appId creation and mapping).
    Whwn i launch the app and click "Register for Puh Notification", I got three alerts, Device Token :'some xyz' ,Subscribed for push Notification and Login success.
    Even though i got all those, My push console says, "You currently have 0 iOS clients, 0 Android clients subscribed to push notifications".
    Since no subscription in console, i am unable to receive notification.

    Please give your thoughts .


    Thanks

    ReplyDelete
  18. Hi Muthu,
    Thanks for reading my blog.


    Make sure below things,
    1)Titanium version >= 2.1.0
    2)ti.cloudpush >= 2.0.5
    3)ti.cloud >= 2.1.0

    4)Android Push Configuration (My Apps -> Manage ACS -> DEVELOPMENT -> Settings/Android Push Configuration)

    ReplyDelete
  19. Hi,

    Question: Can a person receive push notifications on Android phone if the application is not running?

    Thank you for the above tutorial and example code. It was VERY helpful!!

    - Mark

    ReplyDelete
  20. HI Mark,



    Thanks for reading my blog.


    Yes, even If the application is not running user can receive the push notification.

    - Karthi P

    ReplyDelete
  21. Hi, im trying to follow the steps in your tutorial, i already added the module in tiapp.xml, but im failing at step 2, when i try to retrieve the device token im getting this error: "Failed to register for push! com.appcelerator.cloud.push.PushServiceException: Invalid toek request, Message: Unable to generate device token", could you please give me any help with this?, seems like im missing something but i just cant find the problem, thanks!

    ReplyDelete
  22. Hey Karthi,

    Thanks for the reply! I tried to completely kill my test app by going to task manager and completely killing the app, but when I do I never get any push messages. If someone completely kills the app, should I still get push messages? Or do I have to setup a background process to make push messaging work if someone completely kills the app?

    Thanks!!

    - Mark

    ReplyDelete
  23. How can i send push notification to specific client (Phone),
    Please help me

    ReplyDelete
  24. Hi Shanuka, Thanks for reading my blog.


    Yes, you can send push notification to specific client(user).
    For that you have to use "to_ids" property.


    to_ids - Comma separated user ids. Send push notification to the specified users who subscribed to the specified channel.


    Refer this doc for more info https://cloud.appcelerator.com/docs/api/v1/push_notifications/notify

    ReplyDelete
  25. I have the same problem. :/

    ReplyDelete
  26. Hi Elvis,


    Make sure below things,
    1)Titanium version >= 2.1.0
    2)ti.cloudpush >= 2.0.5
    3)ti.cloud >= 2.1.0


    4)Android Push Configuration (My Apps -> Manage ACS -> DEVELOPMENT -> Settings/Android Push Configuration)

    ReplyDelete
  27. When a user clicks on a push notification from their android device shouldn't the app launch? It does on the iPhone. What am I doing wrong?

    ReplyDelete
  28. Hi,


    I have a problem, when I want to get the devicetoken, I got a java.lang.nullpointerexception.


    What could be? :(


    Thx

    ReplyDelete
  29. Hey, send me your sample code to karthi.nkl@gmail.com. Also mention your Ti SDK,ti.cloudpush, ti.clou version

    ReplyDelete
  30. Hmm, everything seems fine in terms of the messages showing up and the registered device showing up on ACS. However, I get nothing on the android device... is this not supposed to work on the android emulator? Mind you, I don't have an android device to test on.

    ReplyDelete
  31. I tried using the code sample to mine, Did every step and finally I was able to see (1) Android device added on the push notification screen.(same as a screen shot on the blog). Then I tried sending the Notification through the test form provided by appcelerator.

    Problem is i never received the notification :(

    Wat can be wrong in this ?

    ReplyDelete
  32. Having same issues: I follow the steps, but never see a notification on the android device. What's going on?

    ReplyDelete
  33. Hi Karthi,

    How to make push messaging work if someone completely kills the app

    I tried to completely kill my test app by going to task manager and completely killing the app, but when I do I never get any push messages. If someone completely kills the app, should I still get push messages? Or do I have to setup a background process to make push messaging work if someone completely kills the app?

    Thats how you defined it - "Push notification allows an app to notify you of new messages or events without the need to actually open the application"

    But the push message is received only if the app is running.

    When the app is killed the push messages are not received

    Thanks!!

    - Mark

    ReplyDelete
  34. I have the same Issue... :( Please suggest.

    ReplyDelete
  35. Hi Im getting This Error :Failed to register for push! com.appcelerator.cloud.push.PushServiceException: Invalid token request. Message:Proper Android Config can not be found, please provide a valid packagename.

    ReplyDelete
  36. It works like a charm. Guys, just follow the tutorial carefully!

    Thank you Karthi!

    ReplyDelete
  37. Hi, I got the messages but don't see 1 Android clients subscribed to push notifications.. help?

    ReplyDelete
  38. If i change it to titanium 2.1.0, it crashes..any idea?

    ReplyDelete
  39. Hi Karthi,

    Good article...

    I have a problem with notifications.

    My question is...

    How to get notifications when new blog topics has been updated ?

    ReplyDelete
  40. Thomas where you put this line in the code ??? I'm working on it but cant see any notification on my device but successfully registered !!
    Thanks

    ReplyDelete
  41. CAn you please share your code with us ??
    I have Titanium version 2.1.2 and sdk 2.1.4
    ti.cloud
    ti.cloudpush
    other \wise I have error on my device "ti.cloud" module not found .. please help

    ReplyDelete
  42. Thanks it worked just fine ,
    my question is : Is it possible to build a custom web application that will do the push notification with the use of Titanium api of course.

    ReplyDelete
  43. Hi Karthi,

    im getting device token alert, and it goes to login function, after tat no alerts received.

    My app response below,

    [INFO][TiVerify(12605)] (Timer-0) [6581,11582] Succesfully verified module licenses

    [INFO][ALERT (12605)] (KrollRuntimeThread) [13,11595] Device Token: ND1KGLLCM67VNIU0DRM5K4F

    [INFO][TiAPI (12605)] ACS Request: { url: "users/login.json", verb: "POST", secure: YES, data: {"login":"basu","password":"pass123"} })

    [INFO][TiAPI (12605)] POST: https://api.cloud.appcelerator.com/v1/users/login.json?oauth_consumer_key=A5XvFBnRLgUo9rJ155SjkgfFDZIdyWpz

    [INFO][TiAPI (12605)] header: {"Authorization":"OAuth realm=\"\",oauth_version=\"1.0\",oauth_consumer_key=\"A5XvFBnRLgUo9rJ155SjkgfFDZIdyWpz\",oauth_signature_method=\"HMAC-SHA1\",oauth_nonce=\"t0Ku8alyFhdlyec\",oauth_timestamp=\"1362479114\",oauth_signature=\"MaLsmxGsGkithex3W3Fl1Y574tU%3D\""}

    [INFO][TiAPI (12605)] data: {"login":"basu","password":"pass123","suppress_response_codes":"true","ti_analytics":"{\"id\":\"0d95db83-31e9-4385-be6c-3ede712c39db\",\"mid\":\"89e31e2ebb7dbb7e\",\"aguid\":\"d5dd7b77-2795-42f7-b62e-d56b5214eda4\",\"event\":\"cloud.users.login\",\"deploytype\":\"test\",\"sid\":\"e3aa2277-79eb-43ba-980d-6a9f5b865681\"}"}



    it doesnt enter success function.
    PLease help!


    Thanks
    Basu

    ReplyDelete
  44. Hi, I am getting same error like "com.appcelerator.cloud.push.PushServiceException: Invalid token request. Message:Proper Android Config can not be found, please provide a valid packagename.". Have you find solution of this?

    ReplyDelete
  45. Hi Karthi,
    We have a similar problem as other people, All works fine if the app is running but if we kill the app and send a notification we dont have any response till we open the app again.
    Can you help us.

    Thanks a lot.

    ReplyDelete
  46. Hi,

    all works fine for me, except I don't receive any notifications...

    Titanium sdk ver. : 2.1.2.GA
    ti.cloudpush : 2.3.0
    ti.cloud : 2.0.7

    Anyone has the same problem and the solution? Thanks

    ReplyDelete
  47. Hi Karthi,

    Thank you for the tutorial and the code, you're awesome :)

    I wonder what should I follow to implement push notifications in the production mode not the development mode. please give me some hints.

    A simple note for readers, check the source code in github, it is more correct/complete than the snippets in the post.

    ReplyDelete
  48. I am not receiving my Google+, yahoo and Facebook notifications. desktop notification software

    ReplyDelete
  49. Can we test push notification service on Android Emulator so that emulator can show notification message?

    ReplyDelete
  50. If you aren't receiving notifications on Android device ensure the

    CloudPush.enabled is set to true using the setEnabled() method

    http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.CloudPush-method-setEnabled

    i.e. CloudPush.setEnabled(true);

    CloudPush.enabled = true; does not always work.

    ReplyDelete
  51. Note:

    Always make sure to call CloudPush.enabled = true; And do so AFTER fetching the device token (so in the success method would be a good place).

    Neglecting this could cause problems when going into production (our simulator didn't give us any trouble).

    ReplyDelete
  52. In my app I didn't receive any notifications until I put this in tiapp.xml

    mqtt

    mqtt

    mqtt

    ReplyDelete
  53. Hi!
    I follow all the steps as in the blog but getting the error of GCM sender ID not found

    ReplyDelete
  54. Any chance we get an updated version for 3.1.3GA? It's not receiving notifications at this moment.

    ReplyDelete
  55. Hi Cleison,
    By Monday(7th of October), I will update this post with Ti SDK 3.1.3 GA.

    ReplyDelete
  56. Thanks, I do appreciate your help not only with this but all the content hosted here.

    ReplyDelete
  57. Cleison, I have done ACS push notification in Ti SDK 3.1.3GA(using GCM). I will update this post by tomorrow.

    ReplyDelete
  58. Thx, can't wait to see it
    :D

    ReplyDelete
  59. Cleison, check out here, http://www.titaniumtutorial.com/2013/10/acs-push-notification-using-gcm.html

    ReplyDelete
  60. it showing error device token should have length 23 characters.

    ReplyDelete
  61. hi, sorry but i have problems...i should use some library or API??? because the emulator show me the next message: [280,0]ti: module.js
    message: Uncaught Error: Requested module not found:ti.cloud
    Source: throw new Error("Requested module not found: " + request);
    I AM SORRY FOR MY BAD ENGLISH... :(

    ReplyDelete
  62. hi,
    Im unable to receive the notifications since I'm getting CloudPush.enabled=true and CloudPush.setEnabled(true) both as false always. please help me out

    ReplyDelete
  63. Hi Dave,

    I tried with both CloudPush.enabled = true; and CloudPush.setEnabled(true); but I'm getting the enabled always as false. Please help me out. Thanks in advance

    ReplyDelete
  64. Awesome Tutorial..works like a charm..Thanks a lot...

    ReplyDelete
  65. Hi, I have written a NEW Titanium Android Module for JPUSH - A Chinese Push Service provider - its working and tested and works really well - visit my site for more details - http://kiteplans.info/2014/04/05/module-appcelerator-titanium-alloy-jpush-push-notification-module-android-china-push-non-gcm/

    ReplyDelete
  66. I've put the sound, icon files in the directory as you said but the response from Ti console is "CloudpushModule: (main) [46057,116137] Failed to find icon resource 'appicon.png' in application"
    and
    "CloudpushModule: (main) [1,116138] Resources/sound/dingdong.wav"

    ReplyDelete
  67. trayClickLaunchedApp event is not working in android and When I click the App gets open but the event is not triggered. My code,
    Cloud = require('ti.cloud');
    Cloud.debug = true;

    CloudPush = require('ti.cloudpush');
    CloudPush.debug = true;
    CloudPush.showTrayNotificationsWhenFocused = true;
    CloudPush.focusAppOnPush = false;
    CloudPush.singleCallback = true;
    CloudPush.showTrayNotification = true;

    CloudPush.addEventListener('callback', function(e){
    alert(JSON.stringify(e));
    });
    CloudPush.addEventListener('trayClickFocusedApp', function(e){
    alert(JSON.stringify(e));
    });
    CloudPush.addEventListener('trayClickLaunchedApp', function(e){
    alert(JSON.stringify(e));
    });

    ReplyDelete
  68. Hi Karthi,

    We have successfully implemented the Push notification and getting messages on devices, But getting "app name stopped working" message randomly,

    And getting this error in console, Can you help to resolve this?

    Error message is :

    [ERROR] : TiApplication: (main) [8470,47940] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to instantiate receiver com.appcelerator.cloud.push.PushBroadcastReceiver: java.lang.ClassNotFoundException: com.appcelerator.cloud.push.PushBroadcastReceiver; Titanium 3.3.0,2014/07/11 12:36,787cd39

    [ERROR] : TiApplication: java.lang.RuntimeException: Unable to instantiate receiver com.appcelerator.cloud.push.PushBroadcastReceiver: java.lang.ClassNotFoundException: com.appcelerator.cloud.push.PushBroadcastReceiver

    [ERROR] : TiApplication: at android.app.ActivityThread.handleReceiver(ActivityThread.java:2265)

    [ERROR] : TiApplication: at android.app.ActivityThread.access$1600(ActivityThread.java:143)

    [ERROR] : TiApplication: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)

    [ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:99)

    [ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:137)

    [ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:4960)

    [ERROR] : TiApplication: at java.lang.reflect.Method.invokeNative(Native Method)

    [ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Method.java:511)

    [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)

    [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)

    [ERROR] : TiApplication: at dalvik.system.NativeStart.main(Native Method)

    [ERROR] : TiApplication: Caused by: java.lang.ClassNotFoundException: com.appcelerator.cloud.push.PushBroadcastReceiver

    [ERROR] : TiApplication: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)

    [ERROR] : TiApplication: at java.lang.ClassLoader.loadClass(ClassLoader.java:501)

    [ERROR] : TiApplication: at java.lang.ClassLoader.loadClass(ClassLoader.java:461)

    [ERROR] : TiApplication: at android.app.ActivityThread.handleReceiver(ActivityThread.java:2260)

    [ERROR] : TiApplication: ... 10 more

    ReplyDelete
  69. Hi,


    I have a problem with Ti SDK 3.4.0 GA. I didn't receive push notifications when I close android app on device.


    Anyone how know solution for this problem?


    Thanks

    ReplyDelete
  70. hi every one i am getting the error some times "no subscription found" and some time failed to authenticate user.

    ReplyDelete
  71. Updated: Appcelerator Titanium Alloy JPUSH Push Notification Module – iOS and Android, China Push Notification- NON GCM - http://kiteplans.info/2015/04/04/appcelerator-titanium-alloy-jpush-push-notification-module-ios-and-android-china-push-notification-non-gcm/

    ReplyDelete