Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Rich push support #34

Merged
merged 44 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
299d243
chore: Dependencies management and publishing workflow updates (#20)
Shahroz16 Sep 24, 2021
69fb401
fix: workflow wrong assemble command
Shahroz16 Sep 24, 2021
6d3be41
Added staging profile id in secrets
Shahroz16 Sep 24, 2021
b28be0e
Updated signing keys secrets
Shahroz16 Sep 24, 2021
8470991
Updated signing id secrets
Shahroz16 Sep 25, 2021
51cedeb
Added semantic versioning to snapshots
Shahroz16 Sep 25, 2021
b447c44
Added missing plugins to dry run
Shahroz16 Sep 25, 2021
76c1647
Added all missing plugins for snapshot release
Shahroz16 Sep 25, 2021
4d18a95
Updated CI workflow for publishing snapshots
Shahroz16 Sep 26, 2021
a22b135
Updated semantic release config
Shahroz16 Sep 26, 2021
3774634
Version issue in snapshot deployment
Shahroz16 Sep 26, 2021
aa81338
Versioning error on sonar type
Shahroz16 Sep 26, 2021
ab48870
Switching back to commit hash as version number
Shahroz16 Sep 26, 2021
2d4cd61
Lowercased snapshot for possible bad request fix
Shahroz16 Sep 26, 2021
54aa850
Snapshot failing possible fix
Shahroz16 Sep 26, 2021
040bbdb
Snapshot test
Shahroz16 Sep 26, 2021
ed82c00
Updated workflow for release artifact
Shahroz16 Sep 26, 2021
8b0355b
Code cleanup
Shahroz16 Sep 27, 2021
272ae32
Removed Kotlin reflect library
Shahroz16 Sep 27, 2021
db919c9
Renamed artifact id to be consistent with iOS
Shahroz16 Sep 28, 2021
aa265c7
Merge branch 'alpha' of github.com:customerio/customerio-android into…
Shahroz16 Sep 29, 2021
cbe61d3
chore: Add network layer and common module (#22)
Shahroz16 Sep 30, 2021
b952c2e
chore: Cio client interface (#25)
Shahroz16 Oct 7, 2021
89f8b08
feat: track event (#28)
Shahroz16 Oct 13, 2021
8d5f104
Merge branch 'alpha' of github.com:customerio/customerio-android into…
Shahroz16 Oct 14, 2021
d3a0d3a
Merge branch 'alpha' of github.com:customerio/customerio-android into…
Shahroz16 Oct 17, 2021
7f12b28
chore: Push notification FCM (#30)
Shahroz16 Oct 29, 2021
e3aaa1c
Removed parent callbacks
Shahroz16 Oct 29, 2021
d6389fe
Added Moshi adapter for data classes
Shahroz16 Oct 29, 2021
767e281
Visibility modifier fixed
Shahroz16 Oct 29, 2021
765f7d1
Added Moshi codegen
Shahroz16 Oct 29, 2021
4e2f5f9
Added app icon as default for push
Shahroz16 Oct 30, 2021
940bd49
fix: typo
Shahroz16 Oct 30, 2021
b0f2a69
Converted unix timestamp to seconds
Shahroz16 Oct 31, 2021
efd7751
Removed notification removal dialog
Shahroz16 Oct 31, 2021
121ba70
Handle new token from client host app
Shahroz16 Oct 31, 2021
7d3ec7f
PR suggestions
Shahroz16 Nov 2, 2021
5b35740
Merge branch 'alpha' of github.com:customerio/customerio-android into…
Shahroz16 Nov 9, 2021
63171f0
Rich push featured added (#33)
Shahroz16 Nov 9, 2021
6a0d0bb
Updated data payload parsing
Shahroz16 Nov 9, 2021
d381be1
Fetch title and body from data/message
Shahroz16 Nov 10, 2021
e0d75bf
Add big image style for notification with image
Shahroz16 Nov 10, 2021
b4c4ac7
Added code docs for deep link
Shahroz16 Nov 10, 2021
21363ce
PR suggestions
Shahroz16 Nov 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/io.customer/android/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.customer.android

object Versions {
internal const val ANDROID_GRADLE_PLUGIN = "7.0.2"
internal const val ANDROID_GRADLE_PLUGIN = "7.0.3"
internal const val ANDROID_JUNIT5_GRADLE_PLUGIN = "1.7.1.1"
internal const val ANDROIDX_TEST_JUNIT = "1.1.3"
internal const val ANDROIDX_APPCOMPAT = "1.3.1"
Expand Down
15 changes: 14 additions & 1 deletion messagingpush/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,25 @@

<!-- Action receiver for push interactions -->
<receiver
android:name=".CustomerIOPushActionReceiver"
android:name=".CustomerIOPushReceiver"
android:exported="false">
<intent-filter>
<action android:name="io.customer.messagingpush.PUSH_ACTION" />
</intent-filter>
</receiver>
</application>

<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
</intent>
</queries>
Comment on lines +27 to +38
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the need of this code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We look for possible applications to open a deep link including browser links and for (API level 30) or higher this is needed to do that.


</manifest>
Original file line number Diff line number Diff line change
@@ -1,33 +1,17 @@
package io.customer.messagingpush

import android.annotation.SuppressLint
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.media.RingtoneManager
import android.os.Build
import android.util.Log
import androidx.core.app.NotificationCompat
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
import io.customer.base.comunication.Action
import io.customer.messagingpush.CustomerIOPushActionReceiver.Companion.ACTION
import io.customer.sdk.CustomerIO
import io.customer.sdk.data.request.MetricEvent
import io.customer.sdk.extensions.getErrorResult
import kotlin.math.abs

class CustomerIOFirebaseMessagingService : FirebaseMessagingService() {

companion object {
private const val TAG = "FirebaseMessaging:"
const val DELIVERY_ID = "CIO-Delivery-ID"
const val DELIVERY_TOKEN = "CIO-Delivery-Token"
const val NOTIFICATION_REQUEST_CODE = "requestCode"

private const val CHANNEL_NAME = "CustomerIO Channel"

/**
* Handles receiving an incoming push notification.
Expand Down Expand Up @@ -84,99 +68,8 @@ class CustomerIOFirebaseMessagingService : FirebaseMessagingService() {
remoteMessage: RemoteMessage,
handleNotificationTrigger: Boolean = true
): Boolean {
// Check if message contains a data payload.
// You can have data only notifications.
if (remoteMessage.data.isEmpty()) {
Log.d(TAG, "Message data payload: " + remoteMessage.data)
return false
}

// Customer.io push notifications include data regarding the push
// message in the data part of the payload which can be used to send
// feedback into our system.
val deliveryId = remoteMessage.data[DELIVERY_ID]
val deliveryToken = remoteMessage.data[DELIVERY_TOKEN]

if (deliveryId != null && deliveryToken != null) {
try {
CustomerIO.instance().trackMetric(
deliveryID = deliveryId,
deviceToken = deliveryToken,
event = MetricEvent.delivered
).enqueue()
} catch (exception: IllegalStateException) {
Log.e(TAG, "Error while handling message: ${exception.message}")
}
}

// Check if message contains a notification payload.
if (remoteMessage.notification != null && handleNotificationTrigger) {
val pushContentIntent = Intent(ACTION)
pushContentIntent.setClass(context, CustomerIOPushActionReceiver::class.java)
pushContentIntent.putExtra(DELIVERY_ID, deliveryId)
pushContentIntent.putExtra(DELIVERY_TOKEN, deliveryToken)

handleNotification(
context,
remoteMessage.notification!!,
pushContentIntent
)
}

return true
}


@SuppressLint("LaunchActivityFromNotification")
private fun handleNotification(
context: Context,
notification: RemoteMessage.Notification,
pushContentIntent: Intent
) {

val requestCode = abs(System.currentTimeMillis().toInt())
pushContentIntent.putExtra(NOTIFICATION_REQUEST_CODE, requestCode)

// In Android 12, you must specify the mutability of each PendingIntent
val flags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
} else {
PendingIntent.FLAG_UPDATE_CURRENT
}

val notificationClickedIntent = PendingIntent.getBroadcast(
context,
requestCode,
pushContentIntent,
flags
)

val icon = context.applicationInfo.icon

val channelId = context.packageName
val defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
val notificationBuilder = NotificationCompat.Builder(context, channelId)
.setSmallIcon(icon)
.setContentTitle(notification.title)
.setContentText(notification.body)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(notificationClickedIntent)

val notificationManager =
context.getSystemService(NOTIFICATION_SERVICE) as NotificationManager

// Since android Oreo notification channel is needed.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(
channelId,
CHANNEL_NAME,
NotificationManager.IMPORTANCE_DEFAULT
)
notificationManager.createNotificationChannel(channel)
}

notificationManager.notify(requestCode, notificationBuilder.build())
val handler = CustomerIOPushNotificationHandler(remoteMessage = remoteMessage)
return handler.handleMessage(context, handleNotificationTrigger)
}

}
Expand Down

This file was deleted.

Loading