Skip to content

Commit 77fc78b

Browse files
author
Devendra
committed
merging mobile_gw_provision
1 parent 8c1db11 commit 77fc78b

File tree

21 files changed

+520
-377
lines changed

21 files changed

+520
-377
lines changed

modern/pubnub.js

+20-9
Original file line numberDiff line numberDiff line change
@@ -1548,36 +1548,48 @@ function PN_API(setup) {
15481548
},
15491549

15501550
/*
1551-
PUBNUB.gcm_add_channel ({
1552-
gcm_regid: 'fun',
1551+
PUBNUB.mobile_gw_provision ({
1552+
device_id: 'A655FBA9931AB',
1553+
op : 'add' | 'remove',
1554+
gw_type : 'apns' | 'gcm',
15531555
channel : 'my_chat',
15541556
callback : fun,
15551557
error : fun,
15561558
});
15571559
*/
15581560

1559-
'gcm_add_channel' : function( args ) {
1561+
'mobile_gw_provision' : function( args ) {
15601562

15611563
var callback = args['callback'] || function(){}
15621564
, auth_key = args['auth_key'] || AUTH_KEY
15631565
, err = args['error'] || function() {}
15641566
, jsonp = jsonp_cb()
15651567
, channel = args['channel']
1566-
, gcm_regid = args['gcm_regid']
1568+
, op = args['op']
1569+
, gw_type = args['gw_type']
1570+
, device_id = args['device_id']
15671571
, url;
15681572

1569-
if (!gcm_regid) return error('Missing GCM Registration ID (gcm_regid)');
1570-
if (!channel) return error('Missing GCM destination Channel (channel)');
1573+
if (!device_id) return error('Missing Device ID (device_id)');
1574+
if (!gw_type) return error('Missing GW Type (gw_type: gcm or apns)');
1575+
if (!op) return error('Missing GW Operation (op: add or remove)');
1576+
if (!channel) return error('Missing gw destination Channel (channel)');
15711577
if (!PUBLISH_KEY) return error('Missing Publish Key');
15721578
if (!SUBSCRIBE_KEY) return error('Missing Subscribe Key');
15731579

15741580
// Create URL
15751581
url = [
15761582
STD_ORIGIN, 'v1/push/sub-key',
1577-
SUBSCRIBE_KEY, 'devices', gcm_regid
1583+
SUBSCRIBE_KEY, 'devices', device_id
15781584
];
15791585

1580-
params = { 'uuid' : UUID, 'auth' : auth_key, 'type': 'gcm', 'add': channel }
1586+
params = { 'uuid' : UUID, 'auth' : auth_key, 'type': gw_type};
1587+
1588+
if (op == "add") {
1589+
params['add'] = channel;
1590+
} else if (op == "remove") {
1591+
params['remove'] = channel;
1592+
}
15811593

15821594
xdr({
15831595
callback : jsonp,
@@ -1593,7 +1605,6 @@ function PN_API(setup) {
15931605

15941606
},
15951607

1596-
15971608
/*
15981609
PUBNUB.audit({
15991610
channel : 'my_chat',

modern/pubnub.min.js

+27-27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node.js/pubnub.js

+20-9
Original file line numberDiff line numberDiff line change
@@ -1548,36 +1548,48 @@ function PN_API(setup) {
15481548
},
15491549

15501550
/*
1551-
PUBNUB.gcm_add_channel ({
1552-
gcm_regid: 'fun',
1551+
PUBNUB.mobile_gw_provision ({
1552+
device_id: 'A655FBA9931AB',
1553+
op : 'add' | 'remove',
1554+
gw_type : 'apns' | 'gcm',
15531555
channel : 'my_chat',
15541556
callback : fun,
15551557
error : fun,
15561558
});
15571559
*/
15581560

1559-
'gcm_add_channel' : function( args ) {
1561+
'mobile_gw_provision' : function( args ) {
15601562

15611563
var callback = args['callback'] || function(){}
15621564
, auth_key = args['auth_key'] || AUTH_KEY
15631565
, err = args['error'] || function() {}
15641566
, jsonp = jsonp_cb()
15651567
, channel = args['channel']
1566-
, gcm_regid = args['gcm_regid']
1568+
, op = args['op']
1569+
, gw_type = args['gw_type']
1570+
, device_id = args['device_id']
15671571
, url;
15681572

1569-
if (!gcm_regid) return error('Missing GCM Registration ID (gcm_regid)');
1570-
if (!channel) return error('Missing GCM destination Channel (channel)');
1573+
if (!device_id) return error('Missing Device ID (device_id)');
1574+
if (!gw_type) return error('Missing GW Type (gw_type: gcm or apns)');
1575+
if (!op) return error('Missing GW Operation (op: add or remove)');
1576+
if (!channel) return error('Missing gw destination Channel (channel)');
15711577
if (!PUBLISH_KEY) return error('Missing Publish Key');
15721578
if (!SUBSCRIBE_KEY) return error('Missing Subscribe Key');
15731579

15741580
// Create URL
15751581
url = [
15761582
STD_ORIGIN, 'v1/push/sub-key',
1577-
SUBSCRIBE_KEY, 'devices', gcm_regid
1583+
SUBSCRIBE_KEY, 'devices', device_id
15781584
];
15791585

1580-
params = { 'uuid' : UUID, 'auth' : auth_key, 'type': 'gcm', 'add': channel }
1586+
params = { 'uuid' : UUID, 'auth' : auth_key, 'type': gw_type};
1587+
1588+
if (op == "add") {
1589+
params['add'] = channel;
1590+
} else if (op == "remove") {
1591+
params['remove'] = channel;
1592+
}
15811593

15821594
xdr({
15831595
callback : jsonp,
@@ -1593,7 +1605,6 @@ function PN_API(setup) {
15931605

15941606
},
15951607

1596-
15971608
/*
15981609
PUBNUB.audit({
15991610
channel : 'my_chat',

phonegap/pubnub.js

+20-9
Original file line numberDiff line numberDiff line change
@@ -1548,36 +1548,48 @@ function PN_API(setup) {
15481548
},
15491549

15501550
/*
1551-
PUBNUB.gcm_add_channel ({
1552-
gcm_regid: 'fun',
1551+
PUBNUB.mobile_gw_provision ({
1552+
device_id: 'A655FBA9931AB',
1553+
op : 'add' | 'remove',
1554+
gw_type : 'apns' | 'gcm',
15531555
channel : 'my_chat',
15541556
callback : fun,
15551557
error : fun,
15561558
});
15571559
*/
15581560

1559-
'gcm_add_channel' : function( args ) {
1561+
'mobile_gw_provision' : function( args ) {
15601562

15611563
var callback = args['callback'] || function(){}
15621564
, auth_key = args['auth_key'] || AUTH_KEY
15631565
, err = args['error'] || function() {}
15641566
, jsonp = jsonp_cb()
15651567
, channel = args['channel']
1566-
, gcm_regid = args['gcm_regid']
1568+
, op = args['op']
1569+
, gw_type = args['gw_type']
1570+
, device_id = args['device_id']
15671571
, url;
15681572

1569-
if (!gcm_regid) return error('Missing GCM Registration ID (gcm_regid)');
1570-
if (!channel) return error('Missing GCM destination Channel (channel)');
1573+
if (!device_id) return error('Missing Device ID (device_id)');
1574+
if (!gw_type) return error('Missing GW Type (gw_type: gcm or apns)');
1575+
if (!op) return error('Missing GW Operation (op: add or remove)');
1576+
if (!channel) return error('Missing gw destination Channel (channel)');
15711577
if (!PUBLISH_KEY) return error('Missing Publish Key');
15721578
if (!SUBSCRIBE_KEY) return error('Missing Subscribe Key');
15731579

15741580
// Create URL
15751581
url = [
15761582
STD_ORIGIN, 'v1/push/sub-key',
1577-
SUBSCRIBE_KEY, 'devices', gcm_regid
1583+
SUBSCRIBE_KEY, 'devices', device_id
15781584
];
15791585

1580-
params = { 'uuid' : UUID, 'auth' : auth_key, 'type': 'gcm', 'add': channel }
1586+
params = { 'uuid' : UUID, 'auth' : auth_key, 'type': gw_type};
1587+
1588+
if (op == "add") {
1589+
params['add'] = channel;
1590+
} else if (op == "remove") {
1591+
params['remove'] = channel;
1592+
}
15811593

15821594
xdr({
15831595
callback : jsonp,
@@ -1593,7 +1605,6 @@ function PN_API(setup) {
15931605

15941606
},
15951607

1596-
15971608
/*
15981609
PUBNUB.audit({
15991610
channel : 'my_chat',

0 commit comments

Comments
 (0)