Skip to content

A realtime tracking system library used by Dilivva.

Notifications You must be signed in to change notification settings

ayodelekehinde/RealTime

Repository files navigation

RealTime

Run tests Kotlin

badge-android badge-ios badge-mac badge-watchos badge-tvos badge-jvm

A lightweight Kotlin multiplatform library that handles websocket connection. Uses Ktor websocket under the hood.

Features

  • Connection
  • Reconnection retrials
  • Good error handling
  • Clean APIs
  • Fast and light
  • Multiplatform (iOS/Android)

Adding to your project

Realtime is published on Github packages

Android

Add the maven url to your build.gradle.kts

repositories {
    maven {
        name = "GitHubPackages"
        url = uri("https://maven.pkg.github.com/Cherrio-LLC/RealTime")

        credentials{
            username = "Android"
            password = "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"
        }
    }
}

Include the dependency. Latest version GitHub release (latest by date)

implementation("github.cherrio:realtime-android:<version>")

iOS

You have to add the github token to your .netrc file on home directory like:

machine maven.pkg.github.com
  login iOS
  password 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

Add the source to your Podfile

source 'https://github.com/Cherrio-LLC/RealTimePodspec.git'

Then add

pod 'realtime', '~> 0.1.5'

Usage

Configure realtime on app initialization

Android

Add the initialization to the onCreate of the class extending Application

override fun onCreate() {
    super.onCreate()
    Realtime.configureApp("baseUrl","UserId")
}

iOS

SwiftUi initialize in the struct extending App

init(){
  RealtimeKt.configureApp(baseurl: "baseUrl", username: "iOS")      
}

UIKit is different, you have to initialize in the AppDelegate on didFinishLaunchingWithOptions

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        RealtimeKt.configureApp(baseurl: "baseUrl", username: "iOS")
        return true
}

To connect

Check the example apps

RoadMap

There's a lot of updates to come.

  1. Send generic data
  2. More tests
  3. Improve docs

License

Copyright 2022 Ayodele Kehinde

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.