Code Monkey home page Code Monkey logo

Comments (6)

morinel avatar morinel commented on June 22, 2024

Put this in your app.js:

/* When the app is started */
var lastData = gcm.getLastData();
if (lastData) {
    ... view the notification ...
    gcm.clearLastData();
}

/* And when the app is resumed */
Ti.Android.currentActivity.addEventListener("resume", function() {
    var lastData = gcm.getLastData();
    if (lastData) {
       ... view the notification ...
       gcm.clearLastData();
    }
});

from gcmpush.

patriciapg93 avatar patriciapg93 commented on June 22, 2024

Okey, now it works. I was calling the function twice, my bad.

The problem I have now is that sometimes, when I execute the app and I close it, I don't receive the push. I must open it again (still not receive push) and close it, then I can receive push again. It seems to enter twice in the success function because I can see the Ti.API.Info duplicated (the second one takes a few seconds to appear), but now I'm calling this function once.

Any clue? What am I doing wrong?

Thank you for your time!

from gcmpush.

morinel avatar morinel commented on June 22, 2024

Maybe check the output of adb logcat and verify whether the push is actually received by the device (or simulator).

from gcmpush.

patriciapg93 avatar patriciapg93 commented on June 22, 2024

I've checked the logcat and when I send a push, I can see this:

09-15 12:09:05.795: I/GCM(1534): GCM message  [app_package] 0:1442311746300784%686fe507f9fd7ecd

09-15 12:09:05.895: V/GCMBroadcastReceiver(20289): GCM IntentService class: nl.vanvianen.android.gcm.GCMIntentService

But nothing else, and I don't receive the notification. This happends when I close the app before the second success info..

When I receive push the ouptut is:

09-15 12:13:28.785: I/GCM(1534): GCM message [app_package] 0:1442312009285689%686fe507f9fd7ecd
09-15 12:13:29.465: V/GCMRegistrar(22499): Setting the name of retry receiver class to nl.vanvianen.android.gcm.GCMBroadcastReceiver
09-15 12:13:29.465: V/GCMBroadcastReceiver(22499): GCM IntentService class: nl.vanvianen.android.gcm.GCMIntentService
09-15 12:13:29.485: V/GCMBaseIntentService(22499): Intent service name: GCMIntentService--1
09-15 12:13:29.485: D/GCMIntentService(22499): (IntentService[GCMIntentService--1]) [29,390] Push notification received
09-15 12:13:29.495: D/GCMIntentService(22499): (IntentService[GCMIntentService--1]) [5,395] Message key: Type value: 1
09-15 12:13:29.495: D/GCMIntentService(22499): (IntentService[GCMIntentService--1]) [1,396] Message key: from value: 299548822026
09-15 12:13:29.495: D/GCMIntentService(22499): (IntentService[GCMIntentService--1]) [1,397] Message key: title value: Ajedrez Viladecans
09-15 12:13:29.495: D/GCMIntentService(22499): (IntentService[GCMIntentService--1]) [1,398] Message key: message value: ¡Tienes un nuevo cuestionario!
09-15 12:13:29.495: D/GCMIntentService(22499): (IntentService[GCMIntentService--1]) [1,399] Message key: channelID value: 6045
09-15 12:13:29.495: D/GCMIntentService(22499): (IntentService[GCMIntentService--1]) [2,401] Message key: collapse_key value: do_not_collapse
09-15 12:13:29.565: E/GCMIntentService(22499): (IntentService[GCMIntentService--1]) [67,468] Invalid setting priority, should be int, between PRIORITY_MIN (-2) and PRIORITY_MAX (2)
09-15 12:13:29.575: D/GCMIntentService(22499): (IntentService[GCMIntentService--1]) [5,473] Creating notification...
09-15 12:13:29.585: I/GCMIntentService(22499): (IntentService[GCMIntentService--1]) [16,489] Group: MyNotificationGroup
09-15 12:13:29.595: I/GCMIntentService(22499): (IntentService[GCMIntentService--1]) [7,496] LocalOnly: false
09-15 12:13:29.595: I/GCMIntentService(22499): (IntentService[GCMIntentService--1]) [1,497] Priority: 0
09-15 12:13:29.595: I/GCMIntentService(22499): (IntentService[GCMIntentService--1]) [2,499] Vibrate: true
09-15 12:13:29.595: I/GCMIntentService(22499): (IntentService[GCMIntentService--1]) [1,500] Insistent: false

from gcmpush.

morinel avatar morinel commented on June 22, 2024

Strange, you should see the Push notification received message.

from gcmpush.

patriciapg93 avatar patriciapg93 commented on June 22, 2024

I think it is because of the registrationId. If it's entering twice in the success function but I quit the app before the second success then it's like the first registration doesn't exists and the second one fails or something, so I'm not able to receive any push.

I'm trying to figure out why is the app trying to register for push twice.

from gcmpush.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.