Notix InApp SDK
NOTIX is an audience re-engagement service based on push notifications that work for both desktop and mobile devices.
Contents
Quick start
Watch the video and follow the steps indicated there [Coming soon]
Installation
Connect jitpack
Add the JitPack repository to your build file
jitpack integration documentation
dependencyResolutionManagement {
...
repositories {
...
maven { url 'https://jitpack.io' }
}
}
SDK dependency
Add it to a module build.gradle file in dependencies
implementation ('com.google.firebase:firebase-messaging:23.0.6') {
exclude group: "org.apache.httpcomponents", module: "httpclient"
exclude group: "org.apache.httpcomponents", module: "httpcore"
}
implementation 'com.github.notix-push:inapp-android-sdk:+'
Create SDK files
NotificationResolver.kt
package YOUR-APPLICATION-PACKAGE
import android.content.Intent
import com.notix.notixsdk.INotificationActivityResolver
class NotificationResolver: INotificationActivityResolver {
override fun resolveActivity(intent: Intent): Class<*> {
return when(intent.getStringExtra("event")) {
"main" -> MainActivity::class.java
//"second" -> SecondActivity::class.java
else -> MainActivity::class.java
}
}
}
NotixMessagingServiceImplementation.kt
package YOUR-APPLICATION-PACKAGE
import android.annotation.SuppressLint
import android.app.Notification
import com.google.firebase.messaging.RemoteMessage
import com.notix.notixsdk.NotificationParameters
import com.notix.notixsdk.NotificationsService
import com.notix.notixsdk.NotixFirebaseMessagingService
@SuppressLint("MissingFirebaseInstanceTokenRefresh")
class NotixMessagingServiceImplementation: NotixFirebaseMessagingService() {
override fun onMessageReceived(message: RemoteMessage) {
super.onMessageReceived(message)
val notification = NotificationParameters().apply {
defaults = Notification.DEFAULT_VIBRATE or Notification.DEFAULT_SOUND
title = intent.getStringExtra("title")
text = intent.getStringExtra("text")
smallIcon = R.mipmap.ic_notix
largeIcon = R.mipmap.ic_notix
}
NotificationsService().handleNotification(this, NotificationResolver(), intent, notification)
}
}
Replace YOUR-APPLICATION-PACKAGE with your app package
Configure AndroidManifest
Add it to AndroidManifest.xml file in application part
<service
android:name=".NotixMessagingServiceImplementation"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
Integration code
Add it to onCreate method in your launcher activity (for example MainActivity)
sdk.init(this, "notix-app-id", "notix-auth-token")
Replace notix-app-id and notix-auth-token with your
###Done!
Run app and just send your first notification in https://app.notix.co/messages/create
Features
Audiences
You can also manage user audiences (see link to audiences)
just use:
sdk.audiences.add(this, "custom-audience")
sdk.audiences.delete(this, "custom-audience")
Events
You can specify which screen to open when you click on the push notification. To do this, you need to set a set of Events on the tag settings page and use it when creating a mailing list on the mailing list creation page.
In the code, it will be enough for you to specify in the NotificationResolver.kt file the correspondence event-name -> ConcreteActivity
For example:
override fun resolveActivity(intent: Intent): Class<*> {
return when(intent.getStringExtra("event")) {
"main" -> MainActivity::class.java
"buy" -> BuyActivity::class.java
"news" -> NewsActivity::class.java
else -> MainActivity::class.java
}
}
You can see that matches have been added for the buy and news events