如何在ios中使用libPusher库?

时间:2016-02-15 10:01:17

标签: ios iphone

我正在尝试使用ios中的libPusher库在我的项目中实现聊天应用程序。我对Pusher一无所知。所以,任何人都可以帮助我解决我的问题。

1 个答案:

答案 0 :(得分:2)

请遵循以下教程。它在这里全面定义。

https://github.com/lukeredpath/libPusher

通过它,实现代表。我正在写这个观点。

选择姓名,你必须在你的服务器上提一下,向你周围的一些服务人员求助。

_privateChannelName = channelName; //Mention on server
self.messageFieldName = fieldName; //Mention on server.

_client = [PTPusher pusherWithKey:kPusherKey delegate:self encrypted:YES];     _client.reconnectDelay = 3.0;

_client.authorizationURL = [NSURL URLWithString:kPusherClientAuthorizationURL]; //You have to create authentication also.

[_client connect];

您必须在

下面放置委托方法
- (void)subscribeToPrivateChannel:(NSString *)channelName withFieldName:(NSString *)messagefieldName;
- (void)pusher:(PTPusher *)pusher connectionDidConnect:(PTPusherConnection *)connection;
- (void)pusher:(PTPusher *)pusher connection:(PTPusherConnection *)connection failedWithError:(NSError *)error;
- (void)pusher:(PTPusher *)pusher connection:(PTPusherConnection *)connection didDisconnectWithError:(NSError *)error willAttemptReconnect:(BOOL)reconnect;
- (BOOL)pusher:(PTPusher *)pusher connectionWillConnect:(PTPusherConnection *)connection;
- (BOOL)pusher:(PTPusher *)pusher connectionWillAutomaticallyReconnect:(PTPusherConnection *)connection afterDelay:(NSTimeInterval)delay;
- (void)pusher:(PTPusher *)pusher didSubscribeToChannel:(PTPusherChannel *)channel;
- (void)pusher:(PTPusher *)pusher didUnsubscribeFromChannel:(PTPusherChannel *)channel;
- (void)pusher:(PTPusher *)pusher didFailToSubscribeToChannel:(PTPusherChannel *)channel withError:(NSError *)error;
- (void)pusher:(PTPusher *)pusher willAuthorizeChannel:(PTPusherChannel *)channel withRequest:(NSMutableURLRequest *)request;
- (void)pusher:(PTPusher *)pusher didReceiveErrorEvent:(PTPusherErrorEvent *)errorEvent;

请阅读它们,仔细检查所有内容,然后回过头来讨论现有的问题和问题。

快乐编码。

感谢。