문제

I had tried for one long day to publish message to 2 channels,..But i could make it..

When i trying to publish with one channel i getting the call back..But not in two channel.. What mistake did i made..

This is my code..

pubnub.subscribe({
    channel : channel_name1,
    connect : function() {
        Ti.API.info('Entered Chat...');
    },
    presence : function(m) {
        Ti.API.info('presence..' + JSON.stringify(m));
    },
    disconnect : function() {
         Ti.API.info("Connection Lost.");
    },
    reconnect : function() {
         Ti.API.info("And we're Back!")
    },
    callback : function(message) {
        Ti.API.info(message);
    },
    error : function() {
         Ti.API.info("Lost Connection !!");
    },

});

And Now i publishing like this..

    pubnub.publish({
        channel :[ channel_name1, channel_name2],
        message : {
            text : message,
        },
        callback : function(info) {
            if (!info[0])
                setTimeout(function() {
                    send_a_message(message);
                }, 2000);
        }
    });
}
도움이 되었습니까?

해결책

Multiplexing (using more than one channel) is supported for subscribe, not for publish. To publish to more than one channel, loop through your channel list, and publish to each individually, using forEach(), or similar.

geremy

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top