{"__v":6,"_id":"55af3bafc97a1a0d0022468d","category":{"__v":1,"_id":"5540e63531827a0d007ab216","pages":["55af3bafc97a1a0d0022468d"],"project":"5540ce1b31827a0d007ab1cc","version":"5540ce1c31827a0d007ab1cf","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-04-29T14:09:57.681Z","from_sync":false,"order":9,"slug":"os-x","title":"OS X"},"parentDoc":null,"project":"5540ce1b31827a0d007ab1cc","user":"55a79a4d4a33f92b00b7a111","version":{"__v":31,"_id":"5540ce1c31827a0d007ab1cf","project":"5540ce1b31827a0d007ab1cc","createdAt":"2015-04-29T12:27:08.390Z","releaseDate":"2015-04-29T12:27:08.390Z","categories":["5540ce1c31827a0d007ab1d0","5540d91bbb9e762d00f594ad","5540e5f131827a0d007ab212","5540e5febb9e762d00f594d3","5540e61331827a0d007ab213","5540e6195cf9682100d61afa","5540e62631827a0d007ab214","5540e63031827a0d007ab215","5540e63531827a0d007ab216","5540e63e5cf9682100d61afc","5540e6445cf9682100d61afd","5540e64a5cf9682100d61afe","55a4ff5b2e70c0250038050f","55acb28318eefd0d0071d504","55ae1abe8576b92300291c80","55ae453ef302af23000ac109","55af586d555b900d0036d296","55af91dac8a85321007a53c3","55b9fee204775a2f00628071","55b9ff0e04775a2f00628072","55b9ff4604775a2f00628073","55b9ff5fd72d1e1900276a38","55b9ff7f04775a2f00628074","55b9ff90eb08801900f833e5","55b9ffa5d72d1e1900276a39","55b9ffca04775a2f00628075","55b9fffdd72d1e1900276a3a","56bc2f033ee9e70d008b46af","56c2f6efbbf9ec2d00e0fe4f","57595bbb18760817001e8bbe","57d8d9793916800e003dde53"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-07-22T06:43:59.709Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"[**Download SDK**](https://github.com/Pushwoosh/pushwoosh-mac-sdk)\n[**Sample Project**](https://github.com/Pushwoosh/pushwoosh-mac-sdk/tree/master/Samples/Mac)\n[**SDK API Docs**](https://github.com/Pushwoosh/pushwoosh-mac-sdk/tree/master/Documentation)\n\nTo integrate Pushwoosh into your application:\n\n1. Add **Pushwoosh.framework** to your project.\n\n2. In **Info.plist** add the `Pushwoosh_APPID` key with your Pushwoosh Application ID string value.\n\n3. Required code changes:\n\n3.1. Add import definitions to **AppDelegate.m**.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#import <Pushwoosh/PushNotificationManager.h>\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n3.2. In the `applicationDidFinishLaunching` function add:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (void)applicationDidFinishLaunching:(NSNotification *)aNotification\\n{\\n    //lots of your initialization code\\n \\n    //-----------PUSHWOOSH PART-----------\\n    // set custom delegate for push handling, in our case - view controller\\n    PushNotificationManager * pushManager = [PushNotificationManager pushManager];\\n    pushManager.delegate = self;\\n     \\n    // handling push on app start\\n    [[PushNotificationManager pushManager] handlePushReceived:[aNotification userInfo]];\\n     \\n    // make sure we count app open in Pushwoosh stats\\n    [[PushNotificationManager pushManager] sendAppOpen];\\n     \\n    // register for push notifications!\\n    [[PushNotificationManager pushManager] registerForPushNotifications];\\n }\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n3.3. Add the following code to your **UIApplicationDelegate** (same file as above).\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// system push notification registration success callback, delegate to pushManager\\n- (void)application:(NSApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {\\n\\t[[PushNotificationManager pushManager] handlePushRegistration:deviceToken];\\n}\\n\\n// system push notification registration error callback, delegate to pushManager\\n- (void)application:(NSApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {\\n\\t[[PushNotificationManager pushManager] handlePushRegistrationFailure:error];\\n\\n}\\n\\n// system push notifications callback, delegate to pushManager\\n- (void)application:(NSApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {\\n\\t[[PushNotificationManager pushManager] handlePushReceived:userInfo];\\n}\\n\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n3.4. To handle push notifications add the following function to your **UIApplicationDelegate** (the same file as three steps above)\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (void) onPushAccepted:(PushNotificationManager *)pushManager withNotification:(NSDictionary *)pushNotification onStart:(BOOL)onStart {\\n    NSLog(:::at:::\\\"Push notification received\\\");\\n}\",\n      \"language\": \"objectivec\"\n    }\n  ]\n}\n[/block]\n3.5 Add **libz.dylib** to the project:\n\n* go to Target section\n* open \"Build Phases\" tab\n* open \"Link Binaries With Libraries\"\n* click **\"+\"** \n* search \"libz.dylib\"\n* Click **Add**\n\nRepeat for **libstdc++.dylib** library.\nNote that in Xcode 7 **.dylib** files have **.tbd** extension.\n\nAll done!","excerpt":"","slug":"mac-os-x-push-notification-sdk","type":"basic","title":"Mac OS X Push Notification SDK"}

Mac OS X Push Notification SDK


[**Download SDK**](https://github.com/Pushwoosh/pushwoosh-mac-sdk) [**Sample Project**](https://github.com/Pushwoosh/pushwoosh-mac-sdk/tree/master/Samples/Mac) [**SDK API Docs**](https://github.com/Pushwoosh/pushwoosh-mac-sdk/tree/master/Documentation) 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 **AppDelegate.m**. [block:code] { "codes": [ { "code": "#import <Pushwoosh/PushNotificationManager.h>", "language": "objectivec" } ] } [/block] 3.2. In the `applicationDidFinishLaunching` function add: [block:code] { "codes": [ { "code": "- (void)applicationDidFinishLaunching:(NSNotification *)aNotification\n{\n //lots of your initialization code\n \n //-----------PUSHWOOSH PART-----------\n // set custom delegate for push handling, in our case - view controller\n PushNotificationManager * pushManager = [PushNotificationManager pushManager];\n pushManager.delegate = self;\n \n // handling push on app start\n [[PushNotificationManager pushManager] handlePushReceived:[aNotification userInfo]];\n \n // make sure we count app open in Pushwoosh stats\n [[PushNotificationManager pushManager] sendAppOpen];\n \n // register for push notifications!\n [[PushNotificationManager pushManager] registerForPushNotifications];\n }", "language": "objectivec" } ] } [/block] 3.3. Add the following code to your **UIApplicationDelegate** (same file as above). [block:code] { "codes": [ { "code": "// system push notification registration success callback, delegate to pushManager\n- (void)application:(NSApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {\n\t[[PushNotificationManager pushManager] handlePushRegistration:deviceToken];\n}\n\n// system push notification registration error callback, delegate to pushManager\n- (void)application:(NSApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {\n\t[[PushNotificationManager pushManager] handlePushRegistrationFailure:error];\n\n}\n\n// system push notifications callback, delegate to pushManager\n- (void)application:(NSApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {\n\t[[PushNotificationManager pushManager] handlePushReceived:userInfo];\n}\n", "language": "objectivec" } ] } [/block] 3.4. To handle push notifications add the following function to your **UIApplicationDelegate** (the same file as three steps above) [block:code] { "codes": [ { "code": "- (void) onPushAccepted:(PushNotificationManager *)pushManager withNotification:(NSDictionary *)pushNotification onStart:(BOOL)onStart {\n NSLog(@\"Push notification received\");\n}", "language": "objectivec" } ] } [/block] 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!