# Mac OS X

[**SDK ডাউনলোড করুন**](https://github.com/Pushwoosh/pushwoosh-mac-sdk)\
[**নমুনা প্রজেক্ট**](https://github.com/Pushwoosh/pushwoosh-mac-sdk/tree/master/Samples/Mac)\
[**SDK API ডক্স**](https://github.com/Pushwoosh/pushwoosh-mac-sdk/tree/master/Documentation)

## Pushwoosh.framework লিঙ্ক করা

আপনার `podfile` বা `cartfile`-এ নিম্নলিখিত লাইনগুলি যোগ করে একটি ডিপেন্ডেন্সি ম্যানেজারের মাধ্যমে আপনার প্রজেক্টে `Pushwoosh.framework` যোগ করুন:

<Tabs>
<TabItem label="Podfile">
```
platform :osx, '10.7'

target 'MyApp' do
	pod 'Pushwoosh_mac'
end
```
</TabItem>

<TabItem label="Cartfile">
```
github "Pushwoosh/pushwoosh-mac-sdk"
```
</TabItem>
</Tabs>

বিকল্পভাবে, আপনি আপনার প্রজেক্টের **Build Phases**-এ **Link Binaries With Libraries**-এর মধ্যে ফ্রেমওয়ার্কটি সরাসরি ড্র্যাগ এবং ড্রপ করতে পারেন।

## লাইব্রেরি যোগ করা

আপনার প্রজেক্টের **Build Phases** ট্যাবে, **Link Binaries With Libraries** খুলুন এবং আইটেম যোগ করুন ("+" বোতাম) ক্লিক করুন। আপনার প্রজেক্টে **libz.tbd** এবং **libc++.tbd** লাইব্রেরিগুলি অনুসন্ধান করুন এবং যোগ করুন:

<img src="/pushwoosh-sdk-os-x-1.webp" alt=""/>

## Pushwoosh কন্ট্রোল প্যানেলের সাথে অ্যাপ লিঙ্ক করা

আপনার **Info.plist**-এ, আপনার Pushwoosh অ্যাপ্লিকেশন কোডটিকে ভ্যালু হিসাবে দিয়ে একটি স্ট্রিং টাইপ কী `Pushwoosh_APPID` যোগ করুন।

## AppDelegate পরিবর্তন করা

আপনার AppDelegate-এ নিম্নলিখিত কোডটি যোগ করুন:

<Tabs>
<TabItem label="Swift">
```swift
import PushKit
import Pushwoosh

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

//lots of your initialization code

//-----------PUSHWOOSH PART-----------

NSUserNotificationCenter.default.delegate = Pushwoosh.sharedInstance()?.notificationCenterDelegateProxy

// set custom delegate for push handling, in our case - view controller
Pushwoosh.sharedInstance().delegate = self

// handling push on app start
Pushwoosh.sharedInstance().handlePushReceived(aNotification.userInfo)

// register for push notifications!
Pushwoosh.sharedInstance().registerForPushNotifications()
```
</TabItem>

<TabItem label="Objective-C">
```objective-c
#import <Pushwoosh/Pushwoosh.h>

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    //lots of your initialization code

    //-----------PUSHWOOSH PART-----------

    [NSUserNotificationCenter defaultUserNotificationCenter].delegate = [Pushwoosh sharedInstance].notificationCenterDelegateProxy;

    // set custom delegate for push handling, in our case - view controller
    [Pushwoosh sharedInstance].delegate = self;

    // handling push on app start
    [[Pushwoosh sharedInstance] handlePushReceived:[aNotification userInfo]];

    // register for push notifications!
    [[Pushwoosh sharedInstance] registerForPushNotifications];
 }
```
</TabItem>
</Tabs>

আপনার **UIApplicationDelegate**-এ নিম্নলিখিত কোডটি যোগ করুন (উপরের একই ফাইল)।

<Tabs>
<TabItem label="Swift">
```swift
// system push notification registration success callback, delegate to PWMessagingDelegate
func application(_ application: NSApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
   Pushwoosh.sharedInstance()?.handlePushRegistration(deviceToken)
}

// system push notification registration error callback, delegate to PWMessagingDelegate
func application(_ application: NSApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
   Pushwoosh.sharedInstance()?.handlePushRegistrationFailure(error)
}
```
</TabItem>

<TabItem label="Objective-C">
```objective-c
// system push notification registration success callback, delegate to pushManager
- (void)application:(NSApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
  [[Pushwoosh sharedInstance] handlePushRegistration:deviceToken];
}

// system push notification registration error callback, delegate to pushManager
- (void)application:(NSApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
  [[Pushwoosh sharedInstance] handlePushRegistrationFailure:error];
}
```
</TabItem>
</Tabs>

পুশ নোটিফিকেশন হ্যান্ডেল করার জন্য, আপনার **UIApplicationDelegate**-এ নিম্নলিখিত ফাংশনটি যোগ করুন (তিনটি ধাপ উপরের একই ফাইল):

<Tabs>
<TabItem label="Swift">
```swift
//this event is fired when the push gets received
func pushwoosh(_ pushwoosh: Pushwoosh!, onMessageReceived message: PWMessage!) {
   print("onMessageReceived: \(String(describing: message.payload))")
}

//this event is fired when user taps the notification
func pushwoosh(_ pushwoosh: Pushwoosh!, onMessageOpened message: PWMessage!) {
   print("onMessageOpened: \(String(describing: message.payload))")
}
```
</TabItem>

<TabItem label="Objective-C">
```objective-c
//this event is fired when the push gets received
- (void)pushwoosh:(Pushwoosh *)pushwoosh onMessageReceived:(PWMessage *)message {
    NSLog(@"onMessageReceived: %@", message.payload);
}

//this event is fired when user taps the notification
- (void)pushwoosh:(Pushwoosh *)pushwoosh onMessageOpened:(PWMessage *)message {
    NSLog(@"onMessageOpened: %@", message.payload);
}
```
</TabItem>
</Tabs>

## পুশ নোটিফিকেশন সক্রিয় করা

আপনার টার্গেটে **Signing and** **Capabilities**-এ যান। **+ Capability** চাপুন এবং **Push Notifications** যোগ করুন।

<img src="/pushwoosh-sdk-os-x-2.webp" alt=""/>