customerio / customerio-reactnative

MIT License
25 stars 13 forks source link

Error on iOS #91

Closed adoniscoder closed 1 year ago

adoniscoder commented 1 year ago

Hi, I've added the Customer.io SDK to my app but on iOS the xcode throws error

Screenshot 2023-02-09 at 18 17 10

I've followed all the required steps but it keeps getting this error.

Here is the full copy of my notifcation handler class: ` import Foundation import CioMessagingPushAPN import UserNotifications

@objc
public class MyAppPushNotificationsHandler : NSObject {

  public override init() {}

  @objc(application:deviceToken:)
  public func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    MessagingPush.shared.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
  }

  @objc(application:error:)
  public func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
    MessagingPush.shared.application(application, didFailToRegisterForRemoteNotificationsWithError: error)
  }

  @objc(userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:)
  public func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
    let handled = MessagingPush.shared.userNotificationCenter(center, didReceive: response,
  withCompletionHandler: completionHandler)

    // If the Customer.io SDK does not handle the push, it's up to you to handle it and call the
    // completion handler. If the SDK did handle it, it called the completion handler for you.
    if !handled {
      completionHandler()
    }
  }

  @objc(initializeCioSdk)
  public func initializeCioSdk() {
    // DEV
    CustomerIO.initialize(siteId: "cccc", apiKey: "vvvvv", region: Region.US, configure: nil)

  }
}

`

levibostian commented 1 year ago

Thanks for asking this question, @adoniscoder.

To fix this problem, you need to add another import to your file: import CioTracking.

I am noticing that this import is missing in our docs. I made this fix and it should be live soon. Thanks for bringing this up to us!