Giter VIP home page Giter VIP logo

knock-android's Introduction

Official Knock Android SDK

A client-side Kotlin library to integrate Knock into Android applications.

GitHub Release Jitpack compatible min Android SDK version GitHub license


Knock is a flexible, reliable notifications infrastructure that's built to scale with you. Use our Android SDK to engage users with in-app feeds, setup push notifications, and manage notification preferences.


Documentation

See the documentation for full documentation.

Migrations

See the Migration Guide if upgrading from a previous version.

Installation

1. Add Jitpack repository support in your settings.gradle file

pluginManagement {
    repositories {
        ..
        maven { url 'https://jitpack.io' }
    }
}

dependencyResolutionManagement {
    repositories {
        ..
        maven { url 'https://jitpack.io' }
    }
}

2. Add the implementation to your app build.gradle file

dependencies {
    implementation 'com.github.knocklabs:knock-android:<VERSION>'
}

3. Init the SDK and FeedManager

// Step 1: Early initialization. Ideal place: Application().onCreate() or MainActivity.
Knock.setup(context = "applicationContext", publishableKey = "your-pk", pushChannelId = "apns-channel-id")

// Step 2: Sign in the user. Ideal timing: as soon as you have the userId.
Knock.shared.signIn(userId = "userId", userToken = "userToken")

knock-android's People

Contributors

matgar26 avatar ghecho avatar cjbell avatar

Watchers

Stuart Eccles avatar Brent Anderson avatar  avatar Juan Manuel Azambuja avatar Thomas avatar Jeff Everhart avatar Sam Seely avatar

knock-android's Issues

java.lang.NoSuchFieldError: No static field Companion of type Landroid/util/Log$Companion

While integrating the knock-android version 0.1.2 into my project, I encountered a runtime error related to the Log class: java.lang.NoSuchFieldError: No static field Companion of type Landroid/util/Log$Companion;. This issue seems to stem from an incorrect reference or usage within the SDK

Steps to Reproduce:

Integrate knock-android version 0.1.2 into an Android project.
Perform actions or initialize the SDK to trigger logging (provide specific steps if possible).
Observe the application crash with the mentioned error.
Expected Behavior:

The SDK should utilize the Android Log class without causing any NoSuchFieldError, allowing for normal operation and logging functionality without crashing.

Actual Behavior:

The application crashes due to a NoSuchFieldError related to the Log class when attempting to log messages or perform actions that involve logging.

Potential Causes:

The SDK might be attempting to access a non-existent Companion object on the Android Log class, which is not a pattern used by the Android SDK.
This could be due to a misinterpretation of Kotlin's static access in Java or a mistaken addition in the SDK's logging mechanism.
Suggested Fixes:

Review the SDK's logging implementation to ensure compatibility with standard Android logging practices, particularly avoiding the use of Companion for the Log class.
Test the logging functionality across different Kotlin and Android versions to catch similar issues in the development phase.
Additional Context:

Android Version: 33
Kotlin Version: 1.9.20
Device/Emulator Specifications: Pixel7
Stack Trace (if applicable):

FATAL EXCEPTION: main Process: io.range.app.dev, PID: 12069 java.lang.NoSuchFieldError: No static field Companion of type Landroid/util/Log$Companion; in class Landroid/util/Log; or its superclasses (declaration of 'android.util.Log' appears in /system/framework/framework.jar!classes3.dex)

getUserFeedContent Error

In my Android app, I am using default
val feedOptions = FeedClientOptions()
without any specific Tenant but when I send some test message from WORKFLOW, my android app throws an error when trying fetch the feed content. shown below

218 KnockManager io.range.app.dev D new-message FeedContent failed: com.fasterxml.jackson.module.kotlin.MissingKotlinParameterException: Instantiation of [simple type, class app.knock.client.FeedItem] value failed for JSON property tenant due to missing (therefore NULL) value for creator parameter tenant which is a non-nullable type at [Source: (StringReader); line: 1, column: 5082] (through reference chain: app.knock.client.Feed["entries"]->java.util.ArrayList[0]->app.knock.client.FeedItem["tenant"]) 2024-02-21 21:13:09.487 27096-27246 app.knock.kotlin_client io.range.app.dev D Push: Sending [null,"8","phoenix","heartbeat",{}] 2024-02-21 21:13:09.599 27096-27217 app.knock.kotlin_client io.range.app.dev D Receive: [null,"8","phoenix","phx_reply",{"response":{},"status":"ok"}]

In my assumption, the the Tenant should be optional in val feedOptions = FeedClientOptions() and not mandatory. Please fix asap as its kind of blocker

Here is my code snippet

val feedOptions = FeedClientOptions() feedManager.connectToFeed(feedOptions) feedManager.on("new-message") { Log.d(TAG, "new-message received") feedManager.getUserFeedContent(feedOptions) { result -> result.fold(onSuccess = { feed -> Log.d(TAG, "new-message FeedContent received: $feed") }, onFailure = { e -> Log.d(TAG, "new-message FeedContent failed: $e") }) } }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.