Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

registerPush called twice #51

Open
fadaytak opened this issue Aug 31, 2016 · 3 comments
Open

registerPush called twice #51

fadaytak opened this issue Aug 31, 2016 · 3 comments

Comments

@fadaytak
Copy link

fadaytak commented Aug 31, 2016

hello,
im using SDK 5.4.0 GA and 1.7 version of the module

this is my code

var gcm = require("nl.vanvianen.android.gcm");

/* If the app is started or resumed act on pending data saved when the notification was received */
    var lastData = gcm.getLastData();
    if (lastData) {
        Ti.API.info("Last notification received " + JSON.stringify(lastData));
        gcm.clearLastData();
    }

    gcm.registerPush({
        senderId : 'XXXXXXXX',
        notificationSettings : {
            sound : '', /* Place sound file in platform/android/res/raw/mysound.mp3 */
            smallIcon : 'appicon.png', /* Place icon in platform/android/res/drawable/notification_icon.png */
            largeIcon : 'appicon.png', /* Same */
            vibrate : true, /* Whether the phone should vibrate */
            insistent : true, /* Whether the notification should be insistent */
            group : 'MyNotificationGroup', /* Name of group to group similar notifications together */
            localOnly : false, /* Whether this notification should be bridged to other devices */
            priority : +2, /* Notification priority, from -2 to +2 */
            bigText : true,
            /* You can also set a static value for title, message, or ticker. If you set a value here, the key will be ignored. */
            // title: '',
            // message: '',
            // ticker: ''
            /* Add LED flashing */
            ledOn : 200,
            ledOff : 300
        },
        success : function(event) {
            Ti.API.info("Push registration success: " + JSON.stringify(event));
            synchronize(event);
        },
        error : function(event) {
            Ti.API.error("Push registration error: " + JSON.stringify(event));
            alert("Fail to register for remote push notification");
        },
        callback : function(event) {
            Ti.API.info("Push callback = " + JSON.stringify(event));
            // Called when a notification is received and the app is in the foreground
            //TODO print message notification
            var dialog = Ti.UI.createAlertDialog({
                title : 'Push received',
                message : JSON.stringify(event.data),
                buttonNames : ['View', 'Cancel'],
                cancel : 1
            });
            dialog.addEventListener("click", function(event) {
                dialog.hide();
                if (event.index == 0) {
                    //Do stuff to view the notification
                }
            });
            dialog.show();
        }
    });

and i got a success registration and just after an error message

[INFO] :   Push registration success:     {"registrationId":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX8ny0B0KQa9UrCn8s","success":true}

and just after

[ERROR] :  GCMIntentService: (IntentService[GCMIntentService--2]) [197,4105] Error: INVALID_SENDER
[ERROR] :  GCMModule: (IntentService[GCMIntentService--2]) [1,4106] INVALID_SENDER

something missing? im sure that im calling this library one time !

@morinel
Copy link
Owner

morinel commented Aug 31, 2016

Are you sure you specified the correct senderId as obtained from Google's Developer console?

@fadaytak
Copy link
Author

Yes and I got a correct registration id and juste after the error !!

I'm using it with alloy in a library
but I'm sure that I'm calling the library one time

@fahad86
Copy link

fahad86 commented Oct 31, 2016

I too have seen concurrent modification errors on our servers at the API the endpoint which is used to save the device tokens obtained from successful registration. Highly likely that it is due t the duplicate registration reported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants