การติดตามการส่งข้อความบน iOS
Pushwoosh มี เมธอด API ที่ใช้ติดตามการส่งการแจ้งเตือนแบบพุช แอป iOS ไม่รองรับเมธอดนี้โดยตรง เนื่องจากการแจ้งเตือนแบบพุชใน iOS ถูกจัดการโดย OS ไม่ใช่โดย Pushwoosh SDK อย่างไรก็ตาม คุณสามารถติดตั้งการติดตามการส่งได้โดยการเพิ่ม Pushwoosh Notification Service Extension สำหรับการติดตามการส่งพุชไปยังโปรเจกต์ของคุณ ในที่นี้คุณจะพบขั้นตอนในการติดตั้ง Message Delivery Tracking สำหรับแอป iOS
เพิ่ม Notification Service Extension
Anchor link toใน Xcode เลือก File > New > Target…
เลือก Notification Service Extension และกด Next

- ป้อนชื่อผลิตภัณฑ์และกด Finish
- กด Cancel บนหน้าต่าง Activate scheme

การกดยกเลิกจะทำให้ Xcode ยังคงดีบักแอปของคุณ แทนที่จะเป็นส่วนขยายที่คุณเพิ่งสร้างขึ้น หากคุณเผลอกดเปิดใช้งานไป คุณสามารถสลับกลับไปดีบักแอปของคุณได้ภายใน Xcode
Dependencies สำหรับ Notification Service Extension (สำหรับ CocoaPods เท่านั้น)
Anchor link toหมายเหตุ: หากคุณใช้ Swift Package Manager เพื่อจัดการ dependencies คุณสามารถข้ามขั้นตอนนี้ไปได้ เนื่องจาก dependencies จะถูกเพิ่มโดยอัตโนมัติ
เปิดไฟล์ Podfile
ของคุณและเพิ่ม dependency สำหรับ target:
target 'NotificationServiceExtension' do use_frameworks! pod 'PushwooshXCFramework'end
รันคำสั่งต่อไปนี้ในเทอร์มินัลเพื่อติดตั้ง dependencies:
rm -rf Podfile.lockpod deintegratepod setuppod repo updatepod install
เพิ่มโค้ดสำหรับการติดตามอีเวนต์การส่งข้อความ
Anchor link to- เพิ่มโค้ดต่อไปนี้ไปยังไฟล์ NotificationService.m ของคุณ:
import UserNotificationsimport PushwooshFramework
class NotificationService: UNNotificationServiceExtension {
var contentHandler: ((UNNotificationContent) -> Void)? var bestAttemptContent: UNMutableNotificationContent?
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) { PWNotificationExtensionManager.shared().handle(request, contentHandler: contentHandler) }}
#import "PWNotificationExtensionManager.h"
@interface NotificationService : UNNotificationServiceExtension
@end
@implementation NotificationService
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler { [[PWNotificationExtensionManager sharedManager] handleNotificationRequest:request contentHandler:contentHandler];}
- (void)serviceExtensionTimeWillExpire { // Called just before the extension is terminated by the system. // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.}
@end
- เพิ่ม Pushwoosh_APPID ไปยังไฟล์ info.plist ของ Notification Service Extension ของคุณ
<key>Pushwoosh_APPID</key> <string>XXXXX-XXXXX</string>
แบ่งปันความคิดเห็นของคุณกับเรา
Anchor link toความคิดเห็นของคุณช่วยให้เราสร้างประสบการณ์ที่ดีขึ้น เราจึงยินดีที่จะรับฟังจากคุณหากคุณพบปัญหาใดๆ ในระหว่างขั้นตอนการผสาน SDK หากคุณประสบปัญหาใดๆ โปรดอย่าลังเลที่จะแบ่งปันความคิดเห็นของคุณกับเรา ผ่านแบบฟอร์มนี้