Mac OS X Push Notification SDK

Download SDK
Sample Project
SDK API Docs

To integrate Pushwoosh into your application:

  1. Add Pushwoosh.framework to your project.

  2. In Info.plist add the Pushwoosh_APPID key with your Pushwoosh Application ID string value.

  3. Required code changes:

3.1. Add import definitions to your AppDelegate file.

import PushKit
#import <Pushwoosh/PushNotificationManager.h>

3.2. In the applicationDidFinishLaunching function add:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {

//lots of your initialization code

NSUserNotificationCenter.default.delegate = self

//-----------PUSHWOOSH PART-----------
  
    // set custom delegate for push handling, in our case - view controller
PushNotificationManager.push().delegate = self

// handling push on app start
PushNotificationManager.push().handlePushReceived(launchOptions)

// make sure we count app open in Pushwoosh stats
PushNotificationManager.push().sendAppOpen()

// register for push notifications!
PushNotificationManager.push().registerForPushNotifications()
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    //lots of your initialization code
 
  	[NSUserNotificationCenter defaultUserNotificationCenter].delegate = self;
    //-----------PUSHWOOSH PART-----------
  
    // set custom delegate for push handling, in our case - view controller
    PushNotificationManager * pushManager = [PushNotificationManager pushManager];
    pushManager.delegate = self;
     
    // handling push on app start
    [[PushNotificationManager pushManager] handlePushReceived:[aNotification userInfo]];
     
    // make sure we count app open in Pushwoosh stats
    [[PushNotificationManager pushManager] sendAppOpen];
     
    // register for push notifications!
    [[PushNotificationManager pushManager] registerForPushNotifications];
 }

3.3. Add the following code to your UIApplicationDelegate (same file as above).

// system push notification registration success callback, delegate to pushManager
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
	PushNotificationManager.push().handlePushRegistration(deviceToken as Data!)
  }
	
  // system push notification registration error callback, delegate to pushManager
	func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
  	PushNotificationManager.push().handlePushRegistrationFailure(error)
    }
    
    func userNotificationCenter(_ center: NSUserNotificationCenter, didActivate notification: NSUserNotification) {
        PushNotificationManager.push().handlePushReceived(notification.userInfo)
    }
// system push notification registration success callback, delegate to pushManager
- (void)application:(NSApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
	[[PushNotificationManager pushManager] handlePushRegistration:deviceToken];
}

// system push notification registration error callback, delegate to pushManager
- (void)application:(NSApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
	[[PushNotificationManager pushManager] handlePushRegistrationFailure:error];

}

// system push notifications callback, delegate to pushManager
- (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification { notification.userInfo);
	[[PushNotificationManager pushManager] handlePushReceived:notification.userInfo];
}

3.4. To handle push notifications add the following function to your UIApplicationDelegate (the same file as three steps above)

func onPushAccepted(_ pushManager: PushNotificationManager!, withNotification pushNotification: [AnyHashable : Any]!, onStart: Bool) {
		print("Push notification accepted: \(pushNotification)")
	}
- (void) onPushAccepted:(PushNotificationManager *)pushManager withNotification:(NSDictionary *)pushNotification onStart:(BOOL)onStart {
    NSLog(@"Push notification received");
}

3.5 Add libz.dylib to the project:

  • go to Target section
  • open "Build Phases" tab
  • open "Link Binaries With Libraries"
  • click "+"
  • search "libz.dylib"
  • Click Add

Repeat for libstdc++.dylib library.
Note that in Xcode 7 .dylib files have .tbd extension.

All done!

Mac OS X Push Notification SDK