All Projects → chabokpush → Chabok Demo Ios

chabokpush / Chabok Demo Ios

Licence: mit
IOS version of Chabok push service demo application

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Chabok Demo Ios

Rctrealtimemessagingandroid
Realtime Cloud Messaging React Native SDK for Android
Stars: ✭ 52 (+940%)
Mutual labels:  push-notifications, realtime-messaging
Applozic Ios Sdk
iOS Real Time Chat & Messaging SDK
Stars: ✭ 104 (+1980%)
Mutual labels:  realtime-messaging, ios-sdk
Firebase Ios Sdk
Firebase iOS SDK
Stars: ✭ 3,309 (+66080%)
Mutual labels:  push-notifications, ios-sdk
Countly Sdk Ios
Countly Product Analytics iOS SDK with macOS, watchOS and tvOS support.
Stars: ✭ 585 (+11600%)
Mutual labels:  push-notifications, ios-sdk
Onesignal Ios Sdk
OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your native iOS app with OneSignal. https://onesignal.com
Stars: ✭ 370 (+7300%)
Mutual labels:  push-notifications, ios-sdk
Onesignal Android Sdk
OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your native Android or Amazon app with OneSignal. https://onesignal.com
Stars: ✭ 503 (+9960%)
Mutual labels:  push-notifications
Countly Sdk Android
Countly Product Analytics Android SDK
Stars: ✭ 626 (+12420%)
Mutual labels:  push-notifications
Python Gcm
Python client for Google Cloud Messaging for Android (GCM)
Stars: ✭ 459 (+9080%)
Mutual labels:  push-notifications
Node Pushnotifications
Push notifications for GCM, APNS, MPNS, AMZ (automatic detection from device token)
Stars: ✭ 432 (+8540%)
Mutual labels:  push-notifications
Gatewayworker
Distributed realtime messaging framework based on workerman.
Stars: ✭ 801 (+15920%)
Mutual labels:  realtime-messaging
React Native Calendar Events
📆 React Native Module for iOS and Android Calendar Events
Stars: ✭ 702 (+13940%)
Mutual labels:  ios-sdk
Applozic Android Sdk
Android Real Time Chat & Messaging SDK
Stars: ✭ 611 (+12120%)
Mutual labels:  realtime-messaging
Countly Server
Countly helps you get insights from your application. Available self-hosted or on private cloud.
Stars: ✭ 4,857 (+97040%)
Mutual labels:  push-notifications
Authelia
The Single Sign-On Multi-Factor portal for web apps
Stars: ✭ 11,094 (+221780%)
Mutual labels:  push-notifications
Fcm Django
FCM Django: Send push notifications via django to websites, iOS & android mobile devices through FCM (Firebase Cloud Messaging)
Stars: ✭ 495 (+9800%)
Mutual labels:  push-notifications
Awesome Ios Interview
📲 The curated list of iOS Developer interview questions and answers, Swift & Objective-C
Stars: ✭ 753 (+14960%)
Mutual labels:  ios-sdk
Wsify
Just a tiny, simple and real-time self-hosted pub/sub messaging service
Stars: ✭ 452 (+8940%)
Mutual labels:  realtime-messaging
Diplomat
整合第三方 SDK 微信、微博、 QQ 等为统一的 Diplomat 接口。
Stars: ✭ 672 (+13340%)
Mutual labels:  ios-sdk
Socket.io Push
整合了小米,华为,友盟,谷歌,苹果推送的统一解决方案
Stars: ✭ 605 (+12000%)
Mutual labels:  push-notifications
Gamenetworkingsockets
Reliable & unreliable messages over UDP. Robust message fragmentation & reassembly. P2P networking / NAT traversal. Encryption.
Stars: ✭ 5,795 (+115800%)
Mutual labels:  realtime-messaging

Chabok Push SDK Documentation (ObjectiveC)

Chabok Push provides you with an iOS framework which is compatible with iOS 7 and later.

Required Frameworks

First make sure you have imported MobileCoreServices.framework, SystemConfiguration.framework and CoreData from Linked Library

Required Capabilities

Please check Remote Notifications checkmark in Project Setting > Capabilities > Background Modes Please enable Push Notifications in Project Setting > Capabilities.

Enabling Chabok Push

Then add the Chabok framework which you have downloaded into your workspace. Import it and define a property in your AppDelegate.h to hold the Chabok client singleton instance.

#import <AdpPushClient/AdpPushClient.h>

@interface AppDelegate () <PushClientManagerDelegate>
  @property (nonatomic, strong) PushClientManager *manager;
@end

Then inside your didFinishLaunchingWithOptions method in AppDelegate.m do the below:

For development accounts to select sandbox chabok servers use +setDevelopment:develop

[PushClientManager setDevelopment:YES];

Now create a singleton instance of PushClientManager using defaultManager:

self.manager = [PushClientManager defaultManager];

add your AppDelegate as delegation for callback purposes:

[self.manager addDelegate:self];

call didFinishLaunchingWithOptions of manager

[self.manager application:application didFinishLaunchingWithOptions:launchOptions])

Now define your account APP_ID, SDK_USERNAME and SDK_PASSWORD. You can find your SDK_KEY from the chabok web panel:

[self.manager registerApplication:@"YOUR_APP_ID"
                                   apiKey:@"YOUR_SDK_KEY"
                                 userName:@"SDK_USERNAME"
                                 password:@"SDK_PASSWORD"]

It's time to register the user with a userId

[self.manager registerUser:@"USER_ID"
                              channels:@[@"YOUR_CHANNEL" ]
                   registrationHandler:^(BOOL isRegistered, NSString *userId, NSError *error) {
  // handle registration result from server
}

After the first time registration, self.manager.userId property will be set and you may want to check manager's object to see if it has a registered userId or not.

Enable Notification Delegation

Include the code below inside your AppDelegate.m. These helps Chabok client to handle remote and local notification delegates:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
                                                       fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{
    // Hook and Handle New Remote Notification, must be use for remote payloads
    [self.manager application:application
           didReceiveRemoteNotification:userInfo
                 fetchCompletionHandler:completionHandler];
}


- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error{
    // Hook and handle failure of get Device token from Apple APNS Server
    [self.manager application:application
                  didFailToRegisterForRemoteNotificationsWithError:error];
}

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
    // Manager hook and handle receive Device Token From APNS Server
    [self.manager application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings{
    // Manager hook and Handle iOS 8 remote Notificaiton Settings
    [self.manager application:application didRegisterUserNotificationSettings:notificationSettings];
}

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{
    // Manager Hook and handle receive iOS (4.0 and later) local notification
    [self.manager application:application didReceiveLocalNotification:notification];
}

PushClientManager Delegation Callback

After calling manager.addDelegate(self) as shown above, you can use the following delegates to receive internal events of Chabok framework. These include:

- (void)pushClientManagerDidRegisterUser:(BOOL)registration{
    // called when PushClientManager Registered user Successfully
}


- (void)pushClientManagerDidFailRegisterUser:(NSError *)error{
    // Called When PushClientMangager fail in registerApplication:appVersion:userName:password:
    // Or - registerUser:userId and registerAgainWithUserId:userId
    NSLog(@"%@ %@",@(__PRETTY_FUNCTION__),error);
    // OR
    NSLog(@"%@ %@",@(__PRETTY_FUNCTION__),self.manager.failureError);
}


- (void)pushClientManagerDidReceivedDelivery:(DeliveryMessage *)delivery{
    // Called When PushClientManager has received new delivery from server
}


- (void)pushClientManagerDidReceivedMessage:(PushClientMessage *)message{
    // Called When PushClientManager has been received new message from server
}


- (void)pushClientManagerDidChangedServerConnectionState{
    // Called When PushClientManager Connecting State has been Changed
}


- (void)pushClientManagerDidChangeServerReachiability:(BOOL)reachable
                                          networkType:(PushClientServerReachabilityNetworkType)networkType{
    // Called When PushClientManager Server Reachiability has been Changed
}

Using Observing which require NSNotificationCenter

As an alternative, you can use NSNotificationCenter's observer methods to receive events. To receive events this way, you can add any of these osbervers:

[[NSNotificationCenter defaultCenter] addObserver:self
	selector:@selector(pushClientFailureHandler:)
		name:kPushClientDidFailRegisterUserNotification object:nil];
    
[[NSNotificationCenter defaultCenter] addObserver:self
	selector:@selector(pushClientNewMessageHandler:)
    	name:kPushClientDidReceivedMessageNotification object:nil];
    
[[NSNotificationCenter defaultCenter] addObserver:self
	selector:@selector(pushClientRegistrationHandler:)
		name:kPushClientDidRegisterUserNotification object:nil];
    
[[NSNotificationCenter defaultCenter] addObserver:self
	selector:@selector(pushClientServerConnectionStateHandler:)
    	name:kPushClientDidChangeServerConnectionStateNotification object:nil];
    
[[NSNotificationCenter defaultCenter] addObserver:self
	selector:@selector(pushClientServerReachabilityHandler:)
    	name:kPushClientDidChangeServerReachabilityNotification object:nil];

and then implement following observer methods to receive Chabok events:

- (void)pushClientNewMessageHandler:(NSNotification*)notification{
    PushClientMessage* message = notification.userInfo[@"message"];
    // handle message
}

- (void)pushClientServerConnectionStateHandler:(NSNotification*)notification{
	// self.manager.connectionState will be one of
    // PushClientServerConnectingStartState
    // PushClientServerConnectingState
    // PushClientServerConnectedState
    // PushClientServerDisconnectedState
    // PushClientServerDisconnectedErrorState

}

- (void)pushClientFailureHandler:(NSNotification*)notification{
}

- (void)pushClientServerReachabilityHandler:(NSNotification *)notification{
}

- (void)pushClientRegistrationHandler:(NSNotification *)notification{
}

Channel Subscription

To subscribe to a channel you can use the following:

[self.manager subscribe:@"myAlerts"]; // private (personal) channel
[self.manager subscribe:@"public/sport"]; // public channel

[self.manager unsubscribe:@"public/+"]; // all public channels

Publishing Messages

To publish a message from client to Chabok server, use this:

PushClientMessage *message = [[PushClientMessage alloc]
                                  initWithMessage:@"message body"
                                  withData:@{
                                             @"test": @"value"
                                             }
                                  topic:@"USER_ID/CHANNEL_NAME"];
message.alertText = @"New Message Alert Text";

[self.manager publish:message];

Receive Deliveries

To enable receive of delivery acknowledgements of a published message, you should enable the deliveries before:

self.manager.deliveryChannelEnabeled = YES;

Badge Handling

If you want to reset your application badge number, you can simply:

- (void)applicationDidEnterBackground:(UIApplication *)application {
    [PushClientManager resetBadge];
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
    [PushClientManager resetBadge];
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].