00001 /* 00002 * (c) 2017 BlackBerry Limited. All rights reserved. 00003 * 00004 */ 00005 00006 #ifndef __GD_PUSH_H__ 00007 #define __GD_PUSH_H__ 00008 00009 #import <Foundation/Foundation.h> 00010 #import "GDPortability.h" 00011 00012 // See: http://clang.llvm.org/docs/LanguageExtensions.html 00013 #ifndef __has_extension 00014 #define __has_extension(x) 0 // Compatibility with non-clang compilers. 00015 #endif 00016 00017 #if __has_extension(attribute_deprecated_with_message) 00018 # define DEPRECATE_PUSH_CONNECT_DISCONNECT __attribute__((deprecated("No longer required"))) 00019 # define DEPRECATE_GDPUSHCONNECTION __attribute__((deprecated("GDPushConnection interface has been deprecated"))) 00020 # define DEPRECATE_GDPUSHCHANNELDELEGATE __attribute__((deprecated("GDPushChannelDelegate protocol has been deprecated, use notifications instead."))) 00021 #else 00022 # define DEPRECATE_PUSH_CONNECT_DISCONNECT __attribute__((deprecated)) 00023 # define DEPRECATE_GDPUSHCONNECTION __attribute__((deprecated)) 00024 # define DEPRECATE_GDPUSHCHANNELDELEGATE __attribute__((deprecated)) 00025 #endif 00026 00027 GD_NS_ASSUME_NONNULL_BEGIN 00028 00040 typedef NS_ENUM(NSInteger, GDPushChannelState) 00041 { 00044 GDPushChannelStateNone = 0, 00045 00048 GDPushChannelStateOpen, 00049 00052 GDPushChannelStateClosed, 00053 00056 GDPushChannelStateError 00057 }; 00058 00085 extern NSString* const GDPushChannelOpenedNotification; 00086 00124 extern NSString* const GDPushChannelClosedNotification; 00125 00173 extern NSString* const GDPushChannelErrorNotification; 00174 00211 extern NSString* const GDPushChannelMessageNotification; 00212 00289 extern NSString* const GDPushChannelPingFailedNotification; 00290 00310 extern NSString* const GDPushChannelTokenKey; 00311 00328 extern NSString* const GDPushChannelMessageKey; 00329 00349 extern NSString* const GDPushChannelErrorKey; 00350 00397 DEPRECATE_GDPUSHCONNECTION 00398 @protocol GDPushConnectionDelegate 00399 00432 - (void)onStatus:(int)status; 00433 @end 00434 00435 00540 DEPRECATE_GDPUSHCONNECTION 00541 @interface GDPushConnection : NSObject { 00542 } 00543 00555 + (instancetype)sharedConnection; 00556 00569 - (BOOL)isConnected; 00570 00596 - (void)connect DEPRECATE_PUSH_CONNECT_DISCONNECT; 00597 00614 - (void)disconnect DEPRECATE_PUSH_CONNECT_DISCONNECT; 00615 00631 @property (GD_NSNULLABLE_PROP nonatomic, weak) id<GDPushConnectionDelegate> delegate; 00632 00633 @end 00634 00635 00774 DEPRECATE_GDPUSHCHANNELDELEGATE 00775 @protocol GDPushChannelDelegate 00776 00803 - (void)onChannelOpen:(NSString*)token; 00804 00839 - (void)onChannelMessage:(NSString*)data; 00840 00876 - (void)onChannelClose:(NSString*)data; 00877 00923 - (void)onChannelError:(int)error; 00924 00986 - (void)onChannelPingFail:(int)error; 00987 00988 @end 00989 00990 01369 @interface GDPushChannel : NSObject { 01370 @private 01371 void* m_pushChannelInternal; 01372 } 01373 01390 @property (GD_NSNULLABLE_PROP nonatomic, weak) id<GDPushChannelDelegate> delegate DEPRECATE_GDPUSHCHANNELDELEGATE; 01391 01399 @property (nonatomic, readonly) GDPushChannelState state; 01400 01408 - (instancetype)init; 01409 01433 - (void)connect; 01434 01460 - (void)disconnect; 01461 01462 @end 01463 01464 GD_NS_ASSUME_NONNULL_END 01465 01466 #endif /* __GD_PUSH_H__ */