Objective-c to js evalstring not working

i am facing a strange problem in the ios version of my game. i have to pass a string that is url encoded from objective-c code to a global function in my typescript code. the contents of the string to be passed are more or less the same each time, however sometimes the string reaches the global function and sometimes it doesn’t. the error i am getting is :

scriptengine::evalstring script (no filename), failed!
error: syntaxerror: unexpected eof, location: (no filename):1:

now, there are no quotes in the string as it is url encoded and there is no \0 in the string either. still sometimes i get this error and the string doesn’t reach my global function.
can someone tell me why this could be happening and how to fix it?
thanks in advance!
sameer

What version of the editor are you using?

If this is an easily reproducible problem, then maybe provide a demo for testing?

hi,
i am providing the google drive link to the zip file of the project :

https://drive.google.com/file/d/1IdjeCJ9QRVfXPRrcX5p6JSS-jMBwQcKV/view?usp=sharing

when you run it on an ios simulator, first click on clear, then click on transact. a payment gateway will open.

  1. scroll down to where it says card/debit card and click on it. then in the space for card number, put 4111111111111111 or 4 followed by 15 1’s. put 11/23 for the date and any string for the name. put any 3 digits for the CVV and uncheck remember cards. then click on pay at the bottom, and another page will open. click on success… this will invoke the onPaymentSuccess callback in rootviewcontroller.

or

  1. when the gateway opens click on the cross on the top right. this will invoke the onPaymentError callback in rootviewcontroller.

in either case in cocos ui, label1 should show some information regarding the transaction. this information is encoded, so don’t worry about what it says as long as there is some text in label1. now, if you search for the logs “weoru923874weiory9347 - Sending : to method :” (this log is from the file : IOSPlugin.mm in Classes folder) in xcode, you can see that data is being sent to the global function (onDataReceived) of cocos in every case but it is not being received in every case.
you have to click on clear and then on transact and then try either 1 or 2 above randomly and then click on clear and then transact again and then try either 1 or 2 . you have to do this many times. you will see that “weoru923874weiory9347 - Sending : to method :” log is coming each time (which means the global function is being called) but the label1 in the cocos canvas doesn’t get the data every time.

please help.

Thanks. Engineering will follow up again

Hi,
no one from the engineering team contacted me regarding this problem. can you please remind the concerned person(s) to reply to this post of mine. i even took the pains to make a sample project for your team to see. this problem is a deal breaker for my project, so i really need to resolve the issue. PLEASE RESPOND SOON.
thanks in anticipation!

I will follow up with the engineering team.

I’m sorry to reply to you so late. I ran a few tests of your demo and wasn’t able to reproduce your situation.
Can you give me an email address? I can record some of my tests and let you see if my tests are faulty?

hi,
you can record and send me videos of your tests at sameer.raina@reingames.com. i will check what, if anything, you are doing wrong.
in the meantime I have updated the demo project to include a few more logs and have made a recording of the process to follow. hopefully this should guide you to the problem. in the video i initiated two transactions…cancelled one and completed the second, and in both cases the log “weoru923874weiory9347 - Sending : to method :” came, which is in the objective-c method that calls the global function. however the log "weoru923874weiory9347 received in method : onDataReceived, data : " never comes, which is in the global function that is called. in my project i am using this technique to send data back to typescript from objective-c many times with success. it just doesn’t work in this case.
please help!

link to updated project
link to video of screen recording

thank you!

I noticed that the iOS version of your test demo video is 14.1, and the version I tested is 13.6, could it be that the test results are different due to different iOS versions? Can you test the 13.6 version and I will try with 14.x version?

Hi,
Unfortunately when I use any iOS simulator version older than 14.0 with Cocos Creator versions 2.4.3 or 2.4.6(these are the ones I have tried), I get some kind of error. So I am currently using iOS simulator version 14.1 with Cocos Creator version 2.4.6. But I would appreciate it if you tried the versions of Creator and iOS that I am currently using.
Thank you!

Reproduce this problem now. I’ll check with the person in charge tomorrow, thanks.

I’m sorry, after more than 10 times of testing, all of them can be displayed normally, this problem is not reproduced again.
You can start by checking the following issues.

  1. network problem. My side of the access may have multiple network access failure (can also be my network access problems), you check the following your side of the situation is not possible
  2. When opening the trading interface, the app interface may be retired to the background, resulting in no response problem. (In this case, please check) You can listen to the event response of the engine back to the background, print whether this phenomenon, resulting in the failure of interaction.
    You can visit this link to learn how to listen for events
    https://docs.cocos.com/creator/api/en/classes/Game.html#eventhide

Also, I sent you an email with the results of one of my tests. @rsamrry

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.