braintree / popup-bridge-ios

Enable your web view to open pages in an ASWebAuthenticationSession
MIT License
38 stars 20 forks source link

[__NSFrozenDictionaryM _fastCStringContents:]: unrecognized selector sent to instance #39

Closed dmytriigolovanov closed 2 years ago

dmytriigolovanov commented 2 years ago

General information

Issue description

We tried to integrate the library into the Swift project. There build error linked to library source code.

P.S.: We decided that was caused by the combination of the Objective-C lib + Swift project.

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSFrozenDictionaryM _fastCStringContents:]: unrecognized selector sent to instance 0x600000e3acc0'

image image
jaxdesmarais commented 2 years ago

Hello @dmytriigolovanov -

I created a small Swift demo of popup bridge here and am unable to reproduce the error you are seeing. Are you able to provide additional details so we can replicate this error? Information such as the URL you are using (if it's public) as well as any other steps we can take to reproduce the error you are seeing in our demo would be helpful.

dmytriigolovanov commented 2 years ago

Hello @dmytriigolovanov -

I created a small Swift demo of popup bridge here and am unable to reproduce the error you are seeing. Are you able to provide additional details so we can replicate this error? Information such as the URL you are using (if it's public) as well as any other steps we can take to reproduce the error you are seeing in our demo would be helpful.

Hello @jaxdesmarais Thanks for your fast answer!

We tried to test our case in the provided demo project. We added a method for received messages and changed the scheme and URL for test. Unfortunately, the problem was reproduced. In additional debug we decided that instance to which unrecognized selector was sent - data field in params.

params in JSON vieww:

{
    "message":
    {
        "data":
        {
            "cb":
            {
                "cb": "PRIVATE_INFO",
                "cbId": "0123"
            }
        },
        "name": "message_name"
    }
}
jaxdesmarais commented 2 years ago

Thanks for sending over those details @dmytriigolovanov. I've tried out several different URLs on our end and have still been unable to reproduce this error. Are you able to share the URL you are attempting to hit?

dmytriigolovanov commented 2 years ago

Thanks for sending over those details @dmytriigolovanov. I've tried out several different URLs on our end and have still been unable to reproduce this error. Are you able to share the URL you are attempting to hit?

I can share the URL and User-Agent with you (your team), but only in a private message, according to project data accessibility rules. Please, share the contact info (email, skype, twitter, etc.) in reply or send via an email to dmytrii.golovanov@gmail.com

jaxdesmarais commented 2 years ago

Hello @dmytriigolovanov -

Thanks for sending over the sample project. After taking a look at the error, the delegate method:

func popupBridge(_ bridge: POPPopupBridge, receivedMessage messageName: String, data: String?) { }

is expecting a string as the data and getting the following object:

{
    "cb": "PRIVATE_INFO",
    "cbId": "0123"
}

Is there a reason you need to send a dictionary here in the data vs the string the delegate method is expecting?

dmytriigolovanov commented 2 years ago

Hello @dmytriigolovanov -

Thanks for sending over the sample project. After taking a look at the error, the delegate method:

func popupBridge(_ bridge: POPPopupBridge, receivedMessage messageName: String, data: String?) { }

is expecting a string as the data and getting the following object:

{
    "cb": "PRIVATE_INFO",
    "cbId": "0123"
}

Is there a reason you need to send a dictionary here in the data vs the string the delegate method is expecting?

Hello, @jaxdesmarais

Thanks for debugging our issue.

We double-checked the data, which sends from the site and we found out that the major of our events (js messages) is using a dictionary instead of a String value. So, now we need to do the fix on the site side and String-Data (String-Dictionary) mapper on the application side.

In addition: Earlier, we rewrote (for personal use) your SDK to Swift. In it, the method uses Any? for the data parameters. Now, we decided to return the origin SDK. So, we can provide you with the Swift version of your SDK as a separate branch, what do you think?

jaxdesmarais commented 2 years ago

Happy to help and hear you got it resolved on your side @dmytriigolovanov! We are in the process of converting our SDKs to Swift. That said, we'd be happy to review any PRs or use a branch as a reference for the conversion. Feel free to let us know the branch name and we'd be happy to take a look.

I'll close out this issue as the issue mentioned is now resolved, but please feel free to open a PR with the branch you've been working on.