allboatsrise / expo-marketingcloudsdk

Expo module for Salesforce Marketing Cloud SDK
MIT License
12 stars 12 forks source link

Failed to convert token to data type #28

Closed aljazkosirnik-specto closed 9 months ago

aljazkosirnik-specto commented 9 months ago

Hi & thank you for creating this library! I have been trying to solve this issue for a couple of days now, and I can't figure out the solution. When calling

MarketingCloud.setSystemToken(token.data);

this gets executed from the library:

    AsyncFunction("setSystemToken") { (token: String, promise: Promise) in
      do {
        let token = try ExpoMarketingCloudSdkDeviceToken.init(hexString: token)

        SFMCSdk.requestPushSdk { mp in
          mp.setDeviceToken(token.data)
          promise.resolve(mp.deviceToken())
        }
      } catch {
        promise.reject("invalid-hex-token", "Failed to convert token to data type")
      }
    }

and I got back the error Failed to convert token to data type.

I have checked multiple things:

Do you happen to know what the issue would be?

andrejpavlovic commented 9 months ago

Not really sure. Need some more details:

aljazkosirnik-specto commented 9 months ago

Yes of course:

andrejpavlovic commented 9 months ago

You need to use real push tokens though, not expo tokens. Notifications.getDevicePushTokenAsync()

aljazkosirnik-specto commented 9 months ago

My bad, I must have switched it when debugging.

It seems to have gone through now, thank you!!