Heads up! We're sunsetting this forum to streamline our community space.

join us on Discord for support, updates, and all things Snap AR! See you there!
Sign up for our live Camera Kit office hour on July 17 @ 9:30am (PT) / 4:30pm (GMT)

Pre-loading of lenses before camera session start

We are a highly experienced mobile app developer with industry leading knowledge of mobile platforms. We have already started integrating the Snapchat Camera Kit SDK in one of our application which will be definitely come to you to review. However, we would like to understand if the platform has the API which can provide the list of lenses based on the group ID. This is because the application has a feature where application will show the list of lenses and if user taps on any one of them then Camera Kit can directly navigate user to that particular lens.

Secondly, we would also like to optimize the user experience and reduce the load time where application should pre-load the available lenses before user actually opens up the camera screen or starts interacting with the lenses.

So, we wanted to inquire if there are any best practices or specific API methods within the Snapchat Camera Kit SDK that will allow the application to pre-load the lenses. As said the goal is to improve the user experience by minimising any potential delay in lens downloading on camera screen.

If preloading lenses is possible with the SDK, could you please provide us detailed guidance on how best this can achieved? Specifically, We would like to understand the recommended approach for loading and caching lens resources in before user interact with camera. Also please recommend any best practices to optimized the resource loading process.

We appreciate your time and assistance in this matter. Thank you in advance for your support.

Regards,
Technical Team

Answers

  • stevenxu
    stevenxu Posts: 612 👻

    @pocketaapp Welcome to the platform! Thanks for posting here your question. I created a ticket (4932) for our eng to review your question and provide you an answer when they can. Hang tight!

  • arashp
    arashp Posts: 52 🔥🔥

    Hi @pocketaapp, welcome and thanks for the question. We have a guide for downloading Lenses before users open the camera screen. You can find some code samples that capture our best practices in that guide.

    https://docs.snap.com/camera-kit/quick-start/integrate-sdk/integrate-sdk-app/guides/prefetch-lenses

    In addition to that guide, our sample apps--on both Android and iOS--do implement this functionality and so that would be another place to look for what we feel are best practices.

    https://github.com/Snapchat/camera-kit-reference

    Please let us know if this answers what you had in mind.

  • arashp
    arashp Posts: 52 🔥🔥
    edited July 2023 #4

    Hi @pocketaapp, one more note this. If you'd like to get a list of lens ids, given a group id, the repository classes are the place to look. In iOS, for instance, you can use LensRepository.lenses(groupID:)

    On Android, there are two options for getting such Lens Group metadata: camerakitsession.lenses.repository.observe(Available(lensGroups)) or camerakitsession.lenses.repository.get(Available(lensGroups))

  • Hi @arashp,

    Thank you for your prompt reply. We will try this approach and inform you if any further assistance is required.

    Regards,
    Technical Team

Categories