libPusher не получает push-уведомления (obj c)

Я пытаюсь реализовать клиент OS X (10.10) для обменного курса биткойнов в реальном времени с bitstamp.com. Они предлагают отличный API, к сожалению, я не могу получить API WebSocket (https://www.bitstamp.net/websocket/) для работы в приложении OS X Objective C.

Все указывают мне на проект libPusher Github (https://github.com/lukeredpath/libPusher), но Я пробовал буквально все, что мог придумать, я не могу заставить его получать какие-либо толчки 10.10.

Следуя вики-странице, я скачал предварительно скомпилированный статический library и перетащил все файлы в свои проекты (я также убедился, что установлен флажок «копировать»), и мои образцы приложений скомпилировались. К сожалению, я никогда не вижу в консоли ни «событие через блок», ни «событие через делегат». Однако я знаю, что сделки происходили в то же время, так что это не может быть проблемой. Любые идеи?

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
PTPusher* client = [PTPusher pusherWithKey:@"de504dc5763aeef9ff52" delegate:self encrypted:YES];

[client connect];

PTPusherChannel *channel = [client subscribeToChannelNamed:@"live_trades"];

[channel bindToEventNamed:@"trade" handleWithBlock:^(PTPusherEvent *channelEvent) {
    // channelEvent.data is a NSDictionary of the JSON object received
    NSLog(@"event through block"); // <-- never called
}];

[[NSNotificationCenter defaultCenter]
 addObserver:self
 selector:@selector(didReceiveEventNotification:)
 name:PTPusherEventReceivedNotification
 object:client];

[[NSNotificationCenter defaultCenter]
 addObserver:self
 selector:@selector(didReceiveChannelEventNotification:)
 name:PTPusherEventReceivedNotification
 object:channel];

}

- (void)didReceiveEventNotification:(NSNotification *)notification // <-- never called
{
    NSLog(@"event through delegate");
    PTPusherEvent *event = [notification.userInfo objectForKey:PTPusherEventUserInfoKey];
}

person ChristophMa    schedule 29.11.2014    source источник
comment
Соединение происходит? См. в этом примере, как проверить   -  person leggetter    schedule 30.11.2014


Ответы (1)


После разговора с разработчиком я обнаружил проблему:

В моем коде экземпляр PTPusher — это локальная переменная, определенная в файле .m. Однако это должна быть строгая переменная, определенная в файле .h:

@property (strong) PTPusher* client;

Затем в файле .m вы можете легко использовать его (не забудьте его синтезировать!):

self.client = [PTPusher pusherWithKey:@"de504dc5763aeef9ff52" delegate:self encrypted:YES];

[self.client connect];

[[NSNotificationCenter defaultCenter]
 addObserver:self
 selector:@selector(didReceiveEventNotification:)
 name:PTPusherEventReceivedNotification
 object:self.client];

PTPusherChannel *channel = [client subscribeToChannelNamed:@"live_trades"];
person ChristophMa    schedule 01.12.2014