Ably iOS client library
An iOS client library for ably.io, the realtime messaging service, written in Objective-C.
add pod ably to your Podfile. While ably-ios is in development, use this line instead:
- pod "ably", :git => 'https://github.com/thevixac/ably-ios.git', :commit => 'be670f5e6c3'
- git clone https://github.com/ably/ably-ios
- drag the directory ably-ios/ably-ios into your project as a group
- git clone https://github.com/square/SocketRocket.git
- drag the directory SocketRocket/SocketRocket into your project as a group
ARTRealtime * client = [[ARTRealtime alloc] initWithKey:@"xxxxx"];
[client subscribeToStateChanges:^(ARTRealtimeConnectionState state) {
if (state == ARTRealtimeConnected) {
// you are connected
}
}];
ARTRealtimeChannel * channel = [client channel:@"test"];
[channel subscribe:^(ARTMessage * message) {
NSString * content =[message content];
NSLog(@" message is %@", content);
}];
[channel publish:@"Hello, Channel!" cb:^(ARTStatus status) {
if(status != ARTStatusOk) {
//something went wrong.
}
}];
[channel history:^(ARTStatus status, id<ARTPaginatedResult> messagesPage) {
XCTAssertEqual(status, ARTStatusOk);
NSArray *messages = [messagesPage currentItems];
NSLog(@"this page has %d messages", [messages count]);
ARTMessage *message = messages[0];
NSString *messageContent = [message content];
NSLog(@"first item is %@", messageContent);
}];
ARTOptions * options = [[ARTOptions alloc] initWithKey:@"xxxxx"];
options.clientId = @"john.doe";
ARTRealtime * client = [[ARTRealtime alloc] initWithOptions:options];
ARTRealtimeChannel * channel = [client channel:@"test"];
[channel publishPresenceEnter:@"I'm here" cb:^(ARTStatus status) {
if(status != ARTStatusOk) {
//something went wrong
}
}];
[channel presenceHistory:^(ARTStatus status, id<ARTPaginatedResult> presencePage) {
NSArray *messages = [presencePage currentItems];
if(messages) {
ARTPresenceMessage *firstMessage = messages[0];
NSString * content = [firstMessage content];
NSLog(@"first message is %@", content);
}
}];
ARTRest * client = [ARTRest alloc] initWithKey:@"xxxxx"];
ARTRestChannel * channel = [client channel:@"test"];
[channel publish:@"Hello, channel!" cb:^(ARTStatus status){
if(status != ARTStatusOk) {
//something went wrong
}
}];
The library works on iOS8, and uses SocketRocket
The following features are not implemented yet:
- msgpack transportation
The following features are do not have sufficient test coverage:
- app stats
Please visit https://support.ably.io/ for access to our knowledgebase and to ask for any assistance.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Ensure you have added suitable tests and the test suite is passing(
bundle exec rspec
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Copyright (c) 2015 Ably, Licensed under an MIT license. Refer to LICENSE.txt for the license terms.