blackberry.com
BlackBerry Dynamics
Runtime library for macOS applications
from the application developer portal

Single-Source Push Connection Listener or Delegate

Deprecated:
This class is deprecated and will be removed in a future release. Instead of setting a PushConnection delegate, register for notifications as described in the GDReachability class reference.

Errors and state changes that occur when using GDPushConnection are handled by creating a class that implements this protocol.

Code Snippets

The following code snippets illustrate some common tasks.

Print State-Change

 @interface BasicHandler : NSObject <GDPushConnectionDelegate> {}
 @end

 @implementation BasicHandler
 -(void)onStatus:(int)status
 {
     if ( [[GDPushConnection sharedConnection] isConnected] ) {
         NSLog( @"Connected OK. Push Channel service available.");
     }
     else {
         NSLog( @"Push Channel service not available.");
     }
 }
 @end

The above snippet shows a very simple handler for GDPushConnection state-change. The availability of the Push Channel service is written to the system log.

Set Event Handler

 basicDelegate = [[BasicHandler alloc] init];
 connection.delegate = basicDelegate;

The above snippet shows how the above handler could be associated with the Push Connection.