Code Monkey home page Code Monkey logo

Comments (3)

morinel avatar morinel commented on July 2, 2024

Are you maybe calling onRegisterPush from both app start up and app resume?

from gcmpush.

m1ga avatar m1ga commented on July 2, 2024

no, I don't have start or resume registered. I just call the script once in the app.js for now.
The log "REGISTER PUSH" is only called once, thats what is called in my commonjs module:

exports.create = function(opt) {
    return new Push(opt);
};

function Push(opt) {
    var senderID = opt.senderID;

    if (OS_ANDROID) {
        var gcm = require("nl.vanvianen.android.gcm");
        var lastData = gcm.getLastData();
        if (lastData) {
            Ti.API.info("Last notification received " + JSON.stringify(lastData));
            gcm.clearLastData();
        }
    }

    this.registerPush = function(opt) {
        if (OS_ANDROID) {
            console.log("REGISTER PUSH " + senderID);

            gcm.registerPush({
                senderId: senderID,
                notificationSettings: {
                    smallIcon: 'notification_icon.png',
                    /* Place icon in platform/android/res/drawable/notification_icon.png */
                    largeIcon: 'appicon.png',
                    vibrate: true,
                    insistent: false,
                    group: 'MyNotificationGroup',
                    localOnly: false,
                    priority: +2
                },
                success: opt.success,
                error: opt.error,
                callback: opt.callback
            });

        } else {
            Ti.App.iOS.addEventListener('usernotificationsettings', function registerForPush() {
                Ti.App.iOS.removeEventListener('usernotificationsettings', registerForPush);

                Ti.Network.registerForPushNotifications({
                    success: opt.success,
                    error: opt.error,
                    callback: opt.callback
                });
            });
            Ti.App.iOS.registerUserNotificationSettings({
                types: [
                    Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT,
                    Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND,
                    Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE
                ]
            });
        }
    };

    this.subscribe = function(opt) {
        console.log("SUBSCRIBE PUSH " + senderID);
        gcm.subscribe({
            senderId: senderID,
            topic: "/topics/" + opt.topic,
            success: opt.success,
            error: opt.error
        });
    };

}

it looks like the BroadcastReceiver (service?) is calling success again

from gcmpush.

jonasfunk avatar jonasfunk commented on July 2, 2024

I'm seeing this as well. First time called on device the success is only called once, but subsequently it's called 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.