Skip to content

Conversation

legion151
Copy link

We use is7816 successfully in our project. However these patches are needed for this.

@legion151 legion151 changed the base branch from jdk12 to mobi/jdk12 April 16, 2020 08:51
@@ -214,6 +214,8 @@ protocols:
name: didInvalidate
'-tagReaderSession:didDetectTags:':
name: didDetectTags
'-tagReaderSessionDidBecomeActive:':
name: tagReaderSessionDidBecomeActive
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tagReaderSessionDidBecomeActive is not available on iOS

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad, misread.
Anyway its already available in 2.3.10-SNAPSHOT.
The only moment I probably would rename it to match other methods (to didBecomeActive)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found it - thank you!

@@ -77,6 +77,6 @@ protected NFCTagReaderSession() {}
* @since Available in iOS 13.0 and later.
*/
@Method(selector = "connectToTag:completionHandler:")
public native void connectToTag(NFCTag tag, @Block VoidBlock1<NSError> completionHandler);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NFCTag is valid as per iOS api
(actually it should be something like this <T extends NSObject & NFCTag > void connectToTag(T tag... but its overkill)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The api docs tell NFCTag, that's correct. However we use
https://developer.apple.com/documentation/corenfc/nfctagreadersessiondelegate/3075577-tagreadersession?language=objc
to start conversation with the card. this functions has a signature like
(NFCTagReaderSession session, NSArray<?> tags)
on the java side.
However i found no way to cast the objects contained in "tags" to NFCTag class to call connectToTag with it. I am getting exceptions stating that NSObject cannot be cast to NFCTag.
That's why i altered the signature of the connectToTag() function to accept NSObject which works fine for us.

It's been a while since we did this, but I rechecked it today and found no way of accomplishing the cast. Chances are that this can be solved in another way i am not aware of.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so it has to be fixed in delegate callback with marshaller like this
session, @org.robovm.rt.bro.annotation.Marshaler(NSArray.AsListMarshaler.class) List<NFCTag> tags)

Copy link
Author

@legion151 legion151 Apr 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, and thanks for the suggestion - the Marshaller does the job - however i then get the error, that the delegate does not implement the method didDetectTags(....).
Since the signature differs.
Any hints on this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, said that too fast. I now put the signature:
void didDetectTags(NFCTagReaderSession session, @org.robovm.rt.bro.annotation.Marshaler(NSArray.AsListMarshaler.class) List<NFCTag> tags)
to NFCTagReaderSessionDelegate and its adapter in robovm - and implemented the callback accordingly. still i get a classcastexception stating that NSObject cannot be cast to NFCTag.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thanks for letting know, will give it a short investigation (probably marshaller doesn't handle protocols correctly)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any news on this. I tried to figure out a proper way but didn't came very far. :/

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will take a look today

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just tested your dev branch successfully - thanks a lot.

@dkimitsa
Copy link
Owner

sorry missed your PR as wasn't watching own repos. have added comments for lines.
also could you please explain why you need to use NSObject instead of NFCTag ?

@dkimitsa dkimitsa closed this Apr 26, 2020
@dkimitsa
Copy link
Owner

@legion151
hi, please check out this branch, if it works I will crate a PR to master.
https://github.com/dkimitsa/robovm/tree/corenfc-marshaller-fix

@legion151
Copy link
Author

@legion151
hi, please check out this branch, if it works I will crate a PR to master.
https://github.com/dkimitsa/robovm/tree/corenfc-marshaller-fix

Oh sry - oversaw your answer - in case you oversaw mine.
i allready checked it out and it worked fine.

Thanks again

@dkimitsa
Copy link
Owner

np, have create a PR yesterday

dkimitsa added a commit that referenced this pull request Apr 15, 2024
…-to-12

exp2 -- v10.2.2, update to Libcore 12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants