콘텐츠로 건너뛰기

Xamarin iOS SDK

모듈 소스
샘플 다운로드

Xamarin iOS 애플리케이션에 Pushwoosh를 통합하려면:

1. 솔루션에 Pushwoosh.Xamarin.iOS nuget 패키지를 추가합니다.

2. 프로젝트에서 AppDelegate.cs를 열고 using Pushwoosh 줄을 추가하여 Pushwoosh를 연결합니다.

3. Info.plistPushwoosh_APPID 키와 Pushwoosh 애플리케이션 ID 문자열 값을 추가합니다.

4. 다음 import를 구성합니다:

  • 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 통합 과정에서 문제가 발생하면 언제든지 의견을 듣고 싶습니다. 어려움이 있으시면 이 양식을 통해 주저하지 말고 의견을 공유해 주세요.

Was this page useful?