join us on Discord for support, updates, and all things Snap AR! See you there!
How to use RemoteAPI in the Camerakit Flutter Sample
I have tried several methods to use RemoteAPI with the CameraKit SDK Wrappers example Flutter project, but I haven't been successful. Could someone please briefly explain how to use it?
Best Answer
-
Hello @Deniz Çetin, thank you for the question about Remote APIs and Flutter. The Flutter Sample does not include Remote API support at the moment. If you'd like to develop this functionality, you might, first, import the Cat Fact example from our iOS Sample App to the Flutter App.
There are three steps to implementing Remote API in the Flutter app:
Import CatFactLensRemoteApi.swift to your Flutter app project
Pass the RemoteApiServiceProvider() to CameraKit's data provider:
/// Configures the data provider for lenses. Subclasses may override this to customize their data provider. /// - Returns: a configured data provider. open func configureDataProvider() -> DataProviderComponent { // By default, CameraKit will handle data providers (such as device motion), // but if you want to handle specific data provider(s), pass them in here, example: DataProviderComponent( deviceMotion: nil, userData: UserDataProvider(), lensHint: nil, location: nil, mediaPicker: lensMediaProvider ) }
- The Cat Fact Lens is one of the Camera Kit Mobile Sample Lenses, which can be found in the Camera Kit portal. Load this Lens group in your app.
These steps should help avoid some of the errors you encountered. Once you have this working, you can work with your own Remote API Lens and also establish communication between the Lens and Flutter container.
1
Answers
-
@Deniz Çetin Thanks for posting on the forum. I'll ping our Eng to see if they can help out. In the meantime, could you share more details of the methods you tried and what issues or errors you may be seeing ?
Steven
0 -
Thank you for your rapid response. Actually, I faced multiple errors instead of just one so I can't pinpoint a specific issue confidently. My approach involved implementing two examples I found for my specific use case. These examples include CatFactLensRemoteApi.swift from the camera-kit-reference/samples on GitHub and the Button Press example from docs.snap.com, located in the tutorials section under App/Lens Communication.
In my use case I aim to establish a communication between Flutter and Lens, and vice versa. To achieve this, I developed an API and set up a connection within Lens Studio. This connection sends a "closeDoubleTap" message via the API. My objective is to listen the message within Swift and disable the double tap functionality. Additionally, I aim for Swift to communicate with Flutter, informing it of the disabled double tap, which will then be stored in the database.
0 -
Exciting to see the updates on wrist tracking support in CameraKit! This feature has great potential for enhancing AR interactions. For those developing AR projects, partnering with a reliable lead generation company can help reach the right audience effectively.
0 -
Have you solved this?
0