Sdk-android - SnapOdds Android SDK

Related tags

SDK sdk-android
Overview

Documentation

For the full API documentation go to https://snapodds.github.io/sdk-android

Support

In case of any questions or problems please contact us at [email protected].

Requirements

Snapscreen requires at least Android API Level 23 (Android 6.0).

Additionally, Snapscreen requires the Android NDK (Native Development Kit).

Integrating Snapscreen

Github Packages

Create a Personal Access Token on Github

  • Inside your GitHub account:
  • Settings -> Developer Settings -> Personal Access Tokens -> Generate new token
  • Make sure you select the scope read:packages and Generate a token
  • After generating make sure to copy your new personal access token. You cannot see it again! The only option is to generate a new key.

Add Github Packages Repository build.gradle inside the application module

Place a github.properties file containing your Github User ID and Personal Access Token in your project's root directory

gpr.user=GITHUB_USERID
gpr.key=PERSONAL_ACCESS_TOKEN

or alternative set the environment variables GPR_USER and GPR_API_KEY

Then define Github Packages as a repository in your application module's build.gradle by adding the following section.

def githubProperties = new Properties() githubProperties.load(new FileInputStream(rootProject.file("github.properties")))
repositories {
    maven {
        name = "GitHubPackages"
        url = uri("https://maven.pkg.github.com/snapodds/sdk-android")
        
        credentials {        
            /** Create github.properties in root project folder file with     
            ** gpr.usr=GITHUB_USER_ID & gpr.key=PERSONAL_ACCESS_TOKEN 
            ** Or set env variable GPR_USER & GPR_API_KEY if not adding a properties file**/
            username = githubProperties['gpr.usr'] ?: System.getenv("GPR_USER")
            password = githubProperties['gpr.key'] ?: System.getenv("GPR_API_KEY")
        }

        metadataSources {
            mavenPom()
            google()
            mavenCentral()
            artifact()
        }
    }
}

Note: If you have configured your project repositories via settings.gradle and changed the dependencyResolutionManagement to maybe even FAIL_ON_PROJECT_REPOS you might need to change where you define the repository.

Add Dependency to build.gradle inside the application module

dependencies {
    //consume library
    implementation 'com.snapscreen.mobile:sdk-android'
}

Using Snapscreen

Obtain a client ID and secret

Contact Snapscreen to get a clientID and secret for your application.

3. Integrate Snapscreen SDK

In order to initialize Snapscreen, you need to call the following class method in your custom Application class in onCreate()

class MyApplication: Application() {
    
    override fun onCreate() {
        super.onCreate()

        Snapscreen.setup(this, "your-client-id", "your-client-secret", Environment.TEST)
    }
}

If you are provided with a custom backend URL by Snapscreen, you can use the following method to initalize the SDK:

Snapscreen.setup(this, "your-client-id", "your-client-secret", "custom-backend-url")

If preferred, you can additionally set the country and usState information based on your user's location:

Snapscreen.instance?.country = "US Snapscreen.instance?.usState = "NJ"

Once you have initialized Snapscreen, you can also retrieve it by calling

Snapscreen.instance

4. Permissions

Snapscreen uses various Android permissions to function correctly. In detail the following permissions are necessary (and automatically defined by the Snapscreen SDK):

android.permission.INTERNET
Used for accessing the backend services of Snapscreen

android.permission.CAMERA
Used for offering snapping functionality and access to the camera

android.permission.VIBRATE
Used for device feedback during snapping functionality

android.permission.WRITE_EXTERNAL_STORAGE
Used for temporary image storage during processing

Snapping Sports content

In order to snap a TV image and search for Sport event, you need to create and present an instance of SnapFragment via the newInstance class method. You can customize the snap settings by configuring the SnapConfiguration you pass to the initializer. The SnapResultListener will receive a callback once a sport event was successfully snapped.

It is recommended that you present the SnapFragment in it's own Activity.

It is also recommended to present and limit the Activity containing a SnapFragment be limited to portrait orientation.

SnapFragment.newInstance(SnapConfiguration(), this)

Once a sport event was successfully snapped, the following method is called in your SnapResultListener:

override fun snapFragmentDidSnapSportEvent(
        fragment: SnapFragment,
        sportEvent: SportEventSnapResultEntry
    ): Boolean {

    return true
}

The boolean return value indicates if you want the SnapFragment to immediately stop snapping. This is most likely the case since you want to present some follow-up UI for the found sport event.

Before you present the Snap UI, we recommend that you ask for the permission to use the camera with the following code snippet and only redirect the user to the Snap UI when the permission has been granted.

val isGranted = ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED
if (isGranted) {
    startActivity(Intent(context, MySnapActivity::class.java))
} else {
    requestPermissions(arrayOf(Manifest.permission.CAMERA), PERMISSION_REQUEST_CAMERA)
}

Fetching Odds for a sport event

In order to fetch odds for a sport event provided by Snapscreen in a consolidated form, you can use the following call to Snapscreen:

Snapscreen.instance?.getOddsForSportEvent(sportEventId) { snapOddsResult ->
}

The completion block is called either with a valid result or nil. See the documentation for the structure and content of the returned result.

Please note that for fetching odds via Snapscreen we highly recommend setting the country and usState fields on the snapscreen instance to receive accurate results.

Customization - UI & Localization

If you want to customize any aspect of the SnapFragment, including displayed messages as well as colors, you can use the UIConfiguration object on the Snapscreen instance.

Snapscreen.instance?.uiConfiguration?.primaryColor = R.color.primary

Make sure to do all your desired customizations before presenting a SnapFragment. You can also modify the configuration between presentations of the SnapFragment. Modifications while the fragment is present are not guaranteed to be respected.

Using with a simulator or emulator

For snapping Snapscreen has dependencies to native libraries which are only available on actual devices. In order to still be able to develop the rest of your application and all features of SnapscreenKit not related to snapping, you need to add the following configuration in the android section of your application's build.gradle. The universalApk option set to true makes sure that when you are building your application, a universal APK is generated that contains all APK splits just like without the splits option.

splits {
    abi {
        enable true
        reset()
        include 'armeabi-v7a', 'mips', 'x86'
        universalApk true
    }
}

Example

For a sample using the Snapscreen SDK, see the included Example project and reconfigure with your own client ID and secret before running.

Support

In case of any questions or problems please contact us at [email protected].

You might also like...
新浪微博 Android SDK

ReadMe 公告: 鉴于线上服务器出现问题,推荐下载本地aar后上传到自己公司的服务器,保证后续服务稳定, 我们也将尽快重新提供一个稳定的地址供大家使用。 新包地址:https://github.com/sinaweibosdk/weibo_android_sdk/tree/master/2019

Official Appwrite Android SDK 💚  🤖
Official Appwrite Android SDK 💚 🤖

Appwrite Android SDK This SDK is compatible with Appwrite server version 0.8.x. For older versions, please check previous releases. Appwrite is an ope

This App is sending Face capture data over network, built around the latest Android Arcore SDK.
This App is sending Face capture data over network, built around the latest Android Arcore SDK.

AndroidArcoreFacesStreaming From any Android phone ArCore compatible, using this app will send over TCP 5680 bytes messages: The first 5616 bytes is a

Trackingplan for Android SDK
Trackingplan for Android SDK

With Trackingplan for Android you can make sure that your tracking is going as you planned without changing your current analytics stack or code.

Desk360 Mobile Chat SDK for Android

Desk360 Chat Android SDK Introduction Desk360 Live Chat SDK is an open source Android library that provides live support to your customers directly fr

Storyblok Kotlin Multiplatform SDK sample (Android, JVM, JS)

storyblok-mp-SDK-sample *WIP* ... a showcase of the Storyblok Kotlin Multiplatform Client SDK. (Android, JVM, JS, iOS, ...) What's included 🚀 • About

A demo of Rongcloud uniapp sdk integration for compiling debug-apk in Android Studio

Rongcloud-uniapp-sdk-demo A demo of Rongcloud uniapp sdk integration for compiling debug-apk in Android Studio 这是一个为了给uniapp在Android平台打出debug-apk的demo

StreamPack: live streaming SDK for Android based on Secure Reliable Transport

StreamPack: live streaming SDK for Android based on Secure Reliable Transport (SRT) StreamPack brings the best audio/video live technologies together

Judo Android SDK

Judo Android SDK Requirements: Android SDK/API level: Android API 23 or later (it will install in apps with minSDK as low as 19, but rendering is only

Comments
  • App crash when SDK gets initialized later

    App crash when SDK gets initialized later

    Implemented to use the latest SDK (2.1.0) however I got a major issue. The app crashes when I try to setup the snapscreen lib.

    This is the crash

    E/AndroidRuntime: FATAL EXCEPTION: main Process: com.miomni.Miomni, PID: 18892 java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.snapscreen.mobile.SnapscreenTimeService.getCalibrated()' on a null object reference at com.snapscreen.mobile.Snapscreen.checkForTokenAndCalibration(Snapscreen.kt:300) at com.snapscreen.mobile.Snapscreen.(Snapscreen.kt:43) at com.snapscreen.mobile.Snapscreen$Companion.setup(Snapscreen.kt:122) at com.miomni.sportsbook.net.WagerThis.prepareSnapscreen(WagerThis.kt:56) at com.miomni.sportsbook.ui.activities.HomeActivity.lambda$onCreate$1$com-miomni-sportsbook-ui-activities-HomeActivity(HomeActivity.java:108) at com.miomni.sportsbook.ui.activities.HomeActivity$$ExternalSyntheticLambda2.onClick(Unknown Source:2)

    Couldn't figure out the issue in the decompiled source code, I can see that the variable 'scope' gets a value later than the method 'checkForTokenAndCalibration()' was called in the constructor, but it gets a value in the onStart method also - dunno where it gets called, I guess from an SDK activity or a fragment. And it looks that the 'timeService' is null at that point, it'll get initiallized in the constructor later.

    opened by CsabaMiomni 1
Owner
Snapodds
Snapodds
Frogo SDK - SDK Core for Easy Development

SDK for anything your problem to make easier developing android apps

Frogobox 10 Dec 15, 2022
HubSpot Kotlin SDK 🧺 Implementation of HubSpot API for Java/Kotlin in tiny SDK

HubSpot Kotlin SDK ?? Implementation of HubSpot API for Java/Kotlin in tiny SDK

BOOM 3 Oct 27, 2022
AWS SDK for Android. For more information, see our web site:

AWS SDK for Android For new projects, we recommend interacting with AWS using the Amplify Framework. The AWS SDK for Android is a collection of low-le

AWS Amplify 976 Dec 29, 2022
Countly Product Analytics Android SDK

Countly Android SDK We're hiring: Countly is looking for Android SDK developers, full stack devs, devops and growth hackers (remote work). Click this

Countly Team 648 Dec 23, 2022
Android Real Time Chat & Messaging SDK

Android Chat SDK Overview Applozic brings real-time engagement with chat, video, and voice to your web, mobile, and conversational apps. We power emer

Applozic 659 May 14, 2022
Evernote SDK for Android

Evernote SDK for Android version 2.0.0-RC4 Evernote API version 1.25 Overview This SDK wraps the Evernote Cloud API and provides OAuth authentication

Evernote 424 Dec 9, 2022
Air Native Extension (iOS and Android) for the Facebook mobile SDK

Air Native Extension for Facebook (iOS + Android) This is an AIR Native Extension for the Facebook SDK on iOS and Android. It has been developed by Fr

Freshplanet 219 Nov 25, 2022
Android Chat SDK built on Firebase

Chat21 is the core of the open source live chat platform Tiledesk.com. Chat21 SDK Documentation Features With Chat21 Android SDK you can: Send a direc

Chat21 235 Dec 2, 2022
Liquid SDK (Android)

Liquid Android SDK Quick Start to Liquid SDK for Android This document is just a quick start introduction to Liquid SDK for Android. We recommend you

Liquid 17 Nov 12, 2021
AWS SDK for Android. For more information, see our web site:

AWS SDK for Android For new projects, we recommend interacting with AWS using the Amplify Framework. The AWS SDK for Android is a collection of low-le

AWS Amplify 975 Dec 24, 2022