ข้ามไปยังเนื้อหา

การติดตามการส่งข้อความบน iOS

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

เพิ่ม Notification Service Extension

Anchor link to
  1. ใน Xcode เลือก File > New > Target…

  2. เลือก Notification Service Extension และกด Next

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

การกดยกเลิกจะทำให้ Xcode ยังคงดีบักแอปของคุณ แทนที่จะเป็นส่วนขยายที่คุณเพิ่งสร้างขึ้น หากคุณเผลอกดเปิดใช้งานไป คุณสามารถสลับกลับไปดีบักแอปของคุณได้ภายใน Xcode

Dependencies สำหรับ Notification Service Extension (สำหรับ CocoaPods เท่านั้น)

Anchor link to

หมายเหตุ: หากคุณใช้ Swift Package Manager เพื่อจัดการ dependencies คุณสามารถข้ามขั้นตอนนี้ไปได้ เนื่องจาก dependencies จะถูกเพิ่มโดยอัตโนมัติ

เปิดไฟล์ Podfile ของคุณและเพิ่ม dependency สำหรับ target:

Podfile
target 'NotificationServiceExtension' do
use_frameworks!
pod 'PushwooshXCFramework'
end

รันคำสั่งต่อไปนี้ในเทอร์มินัลเพื่อติดตั้ง dependencies:

Terminal window
rm -rf Podfile.lock
pod deintegrate
pod setup
pod repo update
pod install

เพิ่มโค้ดสำหรับการติดตามอีเวนต์การส่งข้อความ

Anchor link to
  1. เพิ่มโค้ดต่อไปนี้ไปยังไฟล์ NotificationService.m ของคุณ:
import UserNotifications
import 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)
}
}
  1. เพิ่ม Pushwoosh_APPID ไปยังไฟล์ info.plist ของ Notification Service Extension ของคุณ
<key>Pushwoosh_APPID</key>
<string>XXXXX-XXXXX</string>

แบ่งปันความคิดเห็นของคุณกับเรา

Anchor link to

ความคิดเห็นของคุณช่วยให้เราสร้างประสบการณ์ที่ดีขึ้น เราจึงยินดีที่จะรับฟังจากคุณหากคุณพบปัญหาใดๆ ในระหว่างขั้นตอนการผสาน SDK หากคุณประสบปัญหาใดๆ โปรดอย่าลังเลที่จะแบ่งปันความคิดเห็นของคุณกับเรา ผ่านแบบฟอร์มนี้