Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16744] Android:Receiving push notification even if cloudPush.enabled is set to false

GitHub Issuen/a
TypeBug
PriorityLow
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 3.2.0, Release 3.2.1, Release 3.2.2
Fix Version/sn/a
ComponentsAndroid, Cloud
Labelsn/a
ReporterRupesh Sharma
AssigneeUnknown
Created2014-03-27T06:56:27.000+0000
Updated2018-02-28T20:04:06.000+0000

Description

Description

Even if CloudPush.enabled property is set to false, I am still able to receive push notification. Instead i have to unsubscribe from channel to really disable push notification for that channel.

Test case

var CloudPush = require('ti.cloudpush');
var deviceToken = null;
 
// Initialize the module
CloudPush.retrieveDeviceToken({
    success: deviceTokenSuccess,
    error: deviceTokenError
});

// Enable push notifications for this device
// Save the device token for subsequent API calls
function deviceTokenSuccess(e) {
    CloudPush.enabled = false; // TO STOP RECEIVING PUSH NOTIFICATION
    deviceToken = e.deviceToken;
    subscribeToChannel();
}

var Cloud = require("ti.cloud");
function subscribeToChannel () {
    // Subscribes the device to the 'test' channel
    // Specify the push type as either 'android' for Android or 'ios' for iOS
    Cloud.PushNotifications.subscribeToken({
        device_token: deviceToken,
        channel: 'test',
        type: Ti.Platform.name == 'android' ? 'android' : 'ios'
    }, function (e) {
        if (e.success) {
            alert('Subscribed');
        } else {
            alert('Error:\n' + ((e.error && e.message) || JSON.stringify(e)));
        }
    });
}



function deviceTokenError(e) {
    alert('Failed to register for push notifications! ' + e.error);
}
 
// Process incoming push notifications
CloudPush.addEventListener('callback', function (evt) {
    alert(evt.payload);
});
// Triggered when the push notifications is in the tray when the app is not running
CloudPush.addEventListener('trayClickLaunchedApp', function (evt) {
    Ti.API.info('Tray Click Launched App (app was not running)');
});
// Triggered when the push notifications is in the tray when the app is running
CloudPush.addEventListener('trayClickFocusedApp', function (evt) {
    Ti.API.info('Tray Click Focused App (app was already running)');
});

Comments

No comments

JSON Source