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

Xamarin iOS SDK

ที่มาของโมดูล
ดาวน์โหลดตัวอย่าง

หากต้องการผสานการทำงาน Pushwoosh กับแอปพลิเคชัน Xamarin iOS ของคุณ:

1. เพิ่ม nuget package Pushwoosh.Xamarin.iOS ไปยังโซลูชันของคุณ

2. ในโปรเจกต์ของคุณ เปิด AppDelegate.cs และเชื่อมต่อ Pushwoosh โดยเพิ่มบรรทัด using Pushwoosh

3. ใน Info.plist ของคุณ เพิ่มคีย์ Pushwoosh_APPID พร้อมกับค่าสตริง Pushwoosh Application ID ของคุณ

4. จัดระเบียบการ imports ต่อไปนี้:

  • using Pushwoosh;
  • using UserNotifications;

5. เพิ่มเมธอดด้านล่างไปยัง คลาส AppDelegate:

public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
PushNotificationManager.PushManager.HandlePushRegistration (deviceToken);
}
public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
{
PushNotificationManager.PushManager.HandlePushRegistrationFailure (error);
}
public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
{
PushNotificationManager.PushManager.HandlePushReceived (userInfo);
}

6. เพิ่มโค้ดด้านล่างไปยังเมธอด public override bool FinishedLaunching(UIApplication app, NSDictionary launchOptions):

PushNotificationManager pushmanager = PushNotificationManager.PushManager;
pushmanager.Delegate = new PushDelegate();
UNUserNotificationCenter.Current.Delegate = pushmanager.notificationCenterDelegate;
if (options != null) {
if (options.ContainsKey (UIApplication.LaunchOptionsRemoteNotificationKey)) {
pushmanager.HandlePushReceived(options);
}
}
pushmanager.RegisterForPushNotifications();

7. เพิ่มคลาสต่อไปนี้ไปยัง AppDelegate:

public class PushDelegate : PushNotificationDelegate
{
public override void OnPushAccepted(PushNotificationManager pushManager, NSDictionary pushNotification)
{
Console.WriteLine(“Push accepted: ” + pushNotification);
}
public override void OnPushReceived(PushNotificationManager pushManager, NSDictionary pushNotification, bool onStart)
{
Console.WriteLine(“Push received: ” + pushNotification);
}
public override void OnDidRegisterForRemoteNotificationsWithDeviceToken(NSString token)
{
Console.WriteLine(“Registered for push notifications: ” + token);
}
public override void OnDidFailToRegisterForRemoteNotificationsWithError(NSError error)
{
Console.WriteLine(“Error: ” + error);
}
}

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

Anchor link to

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