macOS
تنزيل SDK
مشروع نموذجي
وثائق SDK API
قبل دمج SDK، قم بتهيئة منصة macOS في مشروع Pushwoosh الخاص بك. اتبع دليل تهيئة macOS.
ربط Pushwoosh.framework
Anchor link toأضف Pushwoosh.framework إلى مشروعك عبر مدير التبعيات عن طريق وضع الأسطر التالية في podfile أو cartfile الخاص بك:
platform :osx, '10.7'
target 'MyApp' do pod 'Pushwoosh_mac'endgithub "Pushwoosh/pushwoosh-mac-sdk"بدلاً من ذلك، يمكنك ببساطة سحب وإفلات الإطار في Link Binaries With Libraries في Build Phases لمشروعك.
إضافة المكتبات
Anchor link toفي علامة التبويب Build Phases لمشروعك، افتح Link Binaries With Libraries وانقر على إضافة عناصر (زر ”+”). ابحث عن مكتبتي libz.tbd و libc++.tbd وأضفهما إلى مشروعك:

ربط التطبيق بـ Pushwoosh Control Panel
Anchor link toفي Info.plist الخاص بك، أضف مفتاحًا من نوع سلسلة نصية Pushwoosh_APPID مع رمز تطبيق Pushwoosh الخاص بك كقيمة.
تعديل AppDelegate
Anchor link toأضف الكود التالي إلى AppDelegate الخاص بك:
import PushKitimport Pushwoosh
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
// الكثير من كود التهيئة الخاص بك
//-----------جزء PUSHWOOSH-----------
NSUserNotificationCenter.default.delegate = Pushwoosh.sharedInstance()?.notificationCenterDelegateProxy
// تعيين مفوض مخصص للتعامل مع الإشعارات، في حالتنا - وحدة التحكم في العرضPushwoosh.sharedInstance().delegate = self
// التعامل مع الإشعارات عند بدء تشغيل التطبيقPushwoosh.sharedInstance().handlePushReceived(aNotification.userInfo)
// التسجيل في الإشعارات الفورية!Pushwoosh.sharedInstance().registerForPushNotifications()#import <Pushwoosh/Pushwoosh.h>
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification{ // الكثير من كود التهيئة الخاص بك
//-----------جزء PUSHWOOSH-----------
[NSUserNotificationCenter defaultUserNotificationCenter].delegate = [Pushwoosh sharedInstance].notificationCenterDelegateProxy;
// تعيين مفوض مخصص للتعامل مع الإشعارات، في حالتنا - وحدة التحكم في العرض [Pushwoosh sharedInstance].delegate = self;
// التعامل مع الإشعارات عند بدء تشغيل التطبيق [[Pushwoosh sharedInstance] handlePushReceived:[aNotification userInfo]];
// التسجيل في الإشعارات الفورية! [[Pushwoosh sharedInstance] registerForPushNotifications]; }أضف الكود التالي إلى UIApplicationDelegate الخاص بك (نفس الملف أعلاه).
// رد نداء نجاح تسجيل الإشعارات الفورية للنظام، تفويض إلى PWMessagingDelegatefunc application(_ application: NSApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { Pushwoosh.sharedInstance()?.handlePushRegistration(deviceToken)}
// رد نداء خطأ تسجيل الإشعارات الفورية للنظام، تفويض إلى PWMessagingDelegatefunc application(_ application: NSApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { Pushwoosh.sharedInstance()?.handlePushRegistrationFailure(error)}// رد نداء نجاح تسجيل الإشعارات الفورية للنظام، تفويض إلى pushManager- (void)application:(NSApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [[Pushwoosh sharedInstance] handlePushRegistration:deviceToken];}
// رد نداء خطأ تسجيل الإشعارات الفورية للنظام، تفويض إلى pushManager- (void)application:(NSApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { [[Pushwoosh sharedInstance] handlePushRegistrationFailure:error];}للتعامل مع الإشعارات الفورية، أضف الدالة التالية إلى UIApplicationDelegate الخاص بك (نفس الملف المذكور قبل ثلاث خطوات):
// يتم إطلاق هذا الحدث عند استلام الإشعارfunc pushwoosh(_ pushwoosh: Pushwoosh!, onMessageReceived message: PWMessage!) { print("onMessageReceived: \(String(describing: message.payload))")}
// يتم إطلاق هذا الحدث عندما ينقر المستخدم على الإشعارfunc pushwoosh(_ pushwoosh: Pushwoosh!, onMessageOpened message: PWMessage!) { print("onMessageOpened: \(String(describing: message.payload))")}// يتم إطلاق هذا الحدث عند استلام الإشعار- (void)pushwoosh:(Pushwoosh *)pushwoosh onMessageReceived:(PWMessage *)message { NSLog(@"onMessageReceived: %@", message.payload);}
// يتم إطلاق هذا الحدث عندما ينقر المستخدم على الإشعار- (void)pushwoosh:(Pushwoosh *)pushwoosh onMessageOpened:(PWMessage *)message { NSLog(@"onMessageOpened: %@", message.payload);}تمكين الإشعارات الفورية
Anchor link toاذهب إلى Signing and Capabilities في هدفك. اضغط على + Capability وأضف Push Notifications.
