Skip to content

Commit 9b6cafb

Browse files
author
Oleksii Korniienko
authored
Merge pull request #99 from GlobalMessageServices/develop
Bump target SDK API to 34 Bump Kotlin version to 1.9.22 Bump Gradle version to 8.4.0 Bump Dokka version to 1.9.10 Bump version of com.google.gms:google-services to 4.4.2 Bump version of androidx.core:core-ktx to 1.13.1 Bump version of androidx.lifecycle:lifecycle-process to 2.8.3 Bump version of com.google.firebase:firebase-messaging to 24.0.0 Bump version of androidx.work:work-runtime-ktx to 2.9.0
2 parents afce517 + 21f5948 commit 9b6cafb

File tree

10 files changed

+216
-118
lines changed

10 files changed

+216
-118
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,30 @@ on:
33
push:
44
branches:
55
- main
6+
- develop
67
pull_request:
78
types: [opened, synchronize, reopened]
89
jobs:
910
build:
1011
name: Build
11-
runs-on: macos-latest
12+
runs-on: macos-13
1213
steps:
13-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
1415
with:
1516
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
16-
- name: Set up JDK 11
17-
uses: actions/setup-java@v3
17+
- name: Set up JDK 17
18+
uses: actions/setup-java@v4
1819
with:
1920
distribution: 'zulu'
20-
java-version: 11
21+
java-version: 17
2122
- name: Cache SonarCloud packages
22-
uses: actions/cache@v3
23+
uses: actions/cache@v4
2324
with:
2425
path: ~/.sonar/cache
2526
key: ${{ runner.os }}-sonar
2627
restore-keys: ${{ runner.os }}-sonar
2728
- name: Cache Gradle packages
28-
uses: actions/cache@v3
29+
uses: actions/cache@v4
2930
with:
3031
path: ~/.gradle/caches
3132
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
@@ -38,5 +39,8 @@ jobs:
3839
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
3940
with:
4041
api-level: 29
42+
arch: x86_64
43+
profile: Nexus 6
44+
force-avd-creation: false
4145
script: ./gradlew connectedCheck && ./gradlew build sonar --info
4246

README.md

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ allprojects {
111111
}
112112
}
113113
```
114-
Add SDK dependency to your module (app-level) build.gradle. The latest version 1.1.9
114+
Add SDK dependency to your module (app-level) build.gradle. The latest version 1.1.10
115115
```Gradle
116116
dependencies {
117117
...
118118
//or use a newer version if available
119-
'com.github.GlobalMessageServices:Hyber-GMS-SDK-Android:1.1.9'
119+
'com.github.GlobalMessageServices:Hyber-GMS-SDK-Android:1.1.10'
120120
}
121121
```
122122
To use http protocol instead of https, add android:usesCleartextTraffic="true" to your application tag inside android manifest
@@ -566,15 +566,14 @@ override fun prepareNotification(data: Map<String, String>, notificationId: Int)
566566

567567
### Using reply button in notification
568568
The reply button empowers end users to make a response to the push message directly from notification. <br>
569-
It only appears if push message is 2way. <br>
570-
You can catch user's response and process it by using the followed code in BroadcastReceiver:
569+
To display reply button in notification and process the user's response you should create class that extends BroadcastReceiver and override function `onReceive(context: Context?, intent: Intent?)`: <br>
571570
```Kotlin
572-
private val mPlugInReceiver = object : BroadcastReceiver() {
573-
override fun onReceive(context: Context, intent: Intent) {
571+
class MyBroadcastReceiver : BroadcastReceiver() {
572+
573+
override fun onReceive(context: Context?, intent: Intent?) {
574574
val remoteInput = RemoteInput.getResultsFromIntent(intent)
575575
when (intent.action) {
576576
577-
578577
PushSDK.NOTIFICATION_REPLY_INTENT_ACTION -> {
579578
intent.extras?.let {
580579
//get extra data
@@ -585,11 +584,11 @@ private val mPlugInReceiver = object : BroadcastReceiver() {
585584
if (remoteInput != null) {
586585
//get reply text
587586
val reply = remoteInput.getCharSequence(
588-
"pushsdk.remote_input_key"
587+
PushSdkNotificationManager.REMOTE_INPUT_KEY
589588
).toString()
590589
println("reply is: $reply")
591590
592-
// cancel notification to update reply UI
591+
// cancel notification to update notification UI
593592
NotificationManagerCompat.from(context).cancel(tag,id)
594593
}
595594
}
@@ -599,6 +598,39 @@ private val mPlugInReceiver = object : BroadcastReceiver() {
599598
}
600599
}
601600
```
601+
Register MyBroadcastReceiver in AndroidManifest.xml: <br>
602+
```Gradle
603+
<application
604+
...>
605+
...
606+
607+
<receiver
608+
android:name=".handler.MyBroadcastReceiver"
609+
android:exported="true">
610+
<intent-filter>
611+
<action android:name="pushsdk.notification.reply.intent" />
612+
</intent-filter>
613+
</receiver>
614+
</application>
615+
```
616+
Create Intent with MyBroadcastReceiver and manually change function `prepareNotification(data: Map<String, String>, notificationId: Int): NotificationCompat.Builder?` in `MyPushKFirebaseService`: <br>
617+
```Kotlin
618+
override fun prepareNotification(
619+
data: Map<String, String>,
620+
notificationId: Int
621+
): NotificationCompat.Builder? {
622+
val replyIntent = Intent(this, MyBroadcastReceiver::class.java)
623+
624+
return pushSdkNotificationManager.constructNotification(
625+
data,
626+
notificationId,
627+
PushSdkNotificationManager.NotificationStyle.BIG_TEXT,
628+
replyIntent
629+
)
630+
}
631+
```
632+
`Reply button only appears in notifications if push message is 2way and you pass replyIntent into `constructNotification()` function.` <br>
633+
602634
603635
***
604636
# Bubbles
@@ -622,12 +654,13 @@ private val mPlugInReceiver = object : BroadcastReceiver() {
622654
* Manually chang the `NotificationCompat.Builder` object style to NotificationStyle.BUBBLES and pass Intent object with BubbleActivity to the called function constructNotification <br>
623655
It can be achieved by overriding the `prepareNotification()` method
624656
```Kotlin
625-
override fun prepareNotification(data: Map<String, String>): NotificationCompat.Builder? {
657+
override fun prepareNotification(data: Map<String, String>, notificationId: Int): NotificationCompat.Builder? {
626658
return pushSdkNotificationManager.constructNotification(
627659
data,
660+
notificationId,
628661
PushSdkNotificationManager.NotificationStyle.BUBBLES,
629662
bubbleIntent = Intent(this, BubbleActivity::class.java)
630-
663+
)
631664
}
632665
```
633666
@@ -816,9 +849,10 @@ class MessageAdapter(private val messages: MutableList<ChatMessage>) :
816849
### You can change Bubble settings by passing the `BubbleSettings` object to the called function constructNotification
817850
818851
```Kotlin
819-
override fun prepareNotification(data: Map<String, String>): NotificationCompat.Builder? {
852+
override fun prepareNotification(data: Map<String, String>, notificationId: Int): NotificationCompat.Builder? {
820853
return pushSdkNotificationManager.constructNotification(
821854
data,
855+
notificationId,
822856
PushSdkNotificationManager.NotificationStyle.BUBBLES,
823857
bubbleIntent = Intent(this, BubbleActivity::class.java),
824858
bubbleSettings = BubbleSettings(shortLabel = "My custom label")

build.gradle

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33

44

55
buildscript {
6-
ext.kotlin_version = '1.9.10'
7-
ext.gradleVersion = '7.4.2'
8-
ext.dokka_version = "1.8.20"
9-
ext.jacocoVersion = '0.8.10'
6+
ext.kotlin_version = '1.9.22'
7+
ext.gradleVersion = '8.4.0'
8+
ext.dokka_version = "1.9.10"
9+
ext.jacocoVersion = '0.8.12'
1010
repositories {
1111
google()
12-
jcenter()
12+
//jcenter()
13+
mavenCentral()
1314
maven {
1415
url 'https://jitpack.io'
1516
}
@@ -22,7 +23,7 @@ buildscript {
2223
classpath("org.jetbrains.dokka:dokka-gradle-plugin:${dokka_version}")
2324

2425
//noinspection GradleDependency
25-
classpath 'com.google.gms:google-services:4.3.15'
26+
classpath 'com.google.gms:google-services:4.4.2'
2627
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
2728

2829
//test coverage
@@ -34,7 +35,7 @@ buildscript {
3435
}
3536

3637
plugins{
37-
id "org.sonarqube" version "4.3.1.3277"
38+
id "org.sonarqube" version "5.1.0.4882"
3839
}
3940

4041
sonarqube {
@@ -49,7 +50,8 @@ sonarqube {
4950
allprojects {
5051
repositories {
5152
google()
52-
jcenter()
53+
//jcenter()
54+
mavenCentral()
5355
maven {
5456
url 'https://jitpack.io'
5557
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Tue Mar 14 09:23:53 CET 2023
1+
#Tue May 07 14:00:08 CEST 2024
22
distributionBase=GRADLE_USER_HOME
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
43
distributionPath=wrapper/dists
5-
zipStorePath=wrapper/dists
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
65
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists

pushsdkandroid/build.gradle

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@ apply plugin: 'jacoco'
1111
ext.build_version_name = '1.1.9'
1212

1313
android {
14-
compileSdkVersion 33
15-
buildToolsVersion "30.0.3"
14+
namespace = "com.push.android.pushsdkandroid"
1615

16+
buildFeatures {
17+
buildConfig = true
18+
}
19+
1720
defaultConfig {
1821
//applicationId "com.push.android.pushsdkandroid"
1922
minSdkVersion 21
20-
targetSdkVersion 33
23+
compileSdk 34
24+
targetSdkVersion 34
2125
versionCode 1
2226

2327
versionName "${build_version_name}"
@@ -53,15 +57,15 @@ android {
5357
}
5458

5559
kotlinOptions {
56-
jvmTarget=11
60+
jvmTarget = 11
5761
}
5862
}
5963

6064
task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) {
6165

6266
reports {
63-
xml.enabled = true
64-
html.enabled = true
67+
xml { enabled true }
68+
html { enabled true }
6569
}
6670

6771
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
@@ -78,29 +82,25 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'crea
7882
}
7983

8084

81-
82-
83-
84-
8585
dependencies {
8686
implementation fileTree(dir: 'libs', include: ['*.jar'])
8787

8888
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
8989
//implementation 'androidx.appcompat:appcompat:1.3.0'
90-
implementation 'androidx.core:core-ktx:1.10.1'
91-
implementation 'androidx.lifecycle:lifecycle-process:2.6.1'
92-
implementation 'androidx.test:monitor:1.6.1'
90+
implementation 'androidx.core:core-ktx:1.13.1'
91+
implementation 'androidx.lifecycle:lifecycle-process:2.8.3'
92+
implementation 'androidx.test:monitor:1.7.1'
9393
implementation 'androidx.security:security-crypto:1.1.0-alpha06'
9494

9595

9696
testImplementation 'junit:junit:4.13.2'
97-
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0'
97+
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
9898
testImplementation project(path: ':pushsdkandroid')
9999
testImplementation 'org.robolectric:robolectric:4.10.3'
100100

101101

102-
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
103-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
102+
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
103+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
104104

105105
implementation 'android.arch.work:work-runtime:1.0.1'
106106
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.20.0"
@@ -110,17 +110,17 @@ dependencies {
110110
//noinspection GradleDependency
111111
//implementation 'com.google.firebase:firebase-iid:20.2.4'
112112
//noinspection GradleDependency
113-
implementation 'com.google.firebase:firebase-messaging:23.2.1'
113+
implementation 'com.google.firebase:firebase-messaging:24.0.0'
114114

115115
implementation 'io.github.microutils:kotlin-logging:3.0.5'
116116
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
117117

118-
implementation "org.jacoco:org.jacoco.agent:0.8.8:runtime"
118+
implementation "org.jacoco:org.jacoco.agent:0.8.11:runtime"
119119

120120
implementation 'com.google.code.gson:gson:2.10.1'
121121

122122
//WorkManager Version 2.7.0 is required for apps targeting Android 12 (S) or higher
123-
implementation 'androidx.work:work-runtime-ktx:2.8.1'
123+
implementation 'androidx.work:work-runtime-ktx:2.9.0'
124124
}
125125

126126
//get HEAD commit hash

pushsdkandroid/src/androidTest/java/PushSDKAndroidTest.kt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import com.push.android.pushsdkandroid.managers.PushSdkNotificationManager
1010
import com.push.android.pushsdkandroid.settings.BubbleSettings
1111
import com.push.android.pushsdkandroid.utils.Info
1212
import junit.framework.TestCase
13+
import org.junit.Assert.assertEquals
1314
import org.junit.Before
1415
import org.junit.Test
1516
import org.junit.runner.RunWith
@@ -118,14 +119,16 @@ class PushSDKAndroidTest {
118119
remoteMessage2.data,
119120
notificationIdBubbles,
120121
PushSdkNotificationManager.NotificationStyle.BUBBLES,
122+
null,
121123
bubbleIntent = Intent(),
122124
bubbleSettings = BubbleSettings()
123125
)
124126

125127
val construct2Way = notificationManager.constructNotification(
126128
remoteMessage3.data,
127129
notificationManager.getNotificationId(),
128-
PushSdkNotificationManager.NotificationStyle.BIG_TEXT
130+
PushSdkNotificationManager.NotificationStyle.BIG_TEXT,
131+
Intent(appContext, PushSDKAndroidTest::class.java)
129132
)
130133

131134
println(construct1)
@@ -136,11 +139,22 @@ class PushSDKAndroidTest {
136139
println(construct2Way)
137140

138141
val isSent = construct2?.let { notificationManager.sendNotification(it, notificationId) }
142+
val isSent2wWay =
143+
construct2Way?.let { notificationManager.sendNotification(it, notificationId) }
144+
145+
val isSentBubble =
146+
constructBubble?.let { notificationManager.sendNotification(it, notificationIdBubbles) }
147+
148+
139149

140-
val isSentBubble = constructBubble?.let { notificationManager.sendNotification(it, notificationIdBubbles) }
141150

142151
println(isSent)
152+
println(isSent2wWay)
143153
println(isSentBubble)
154+
155+
assertEquals(true, isSent)
156+
assertEquals(true, isSent2wWay)
157+
144158
}
145159

146160
@Test
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest package="com.push.android.pushsdkandroid">
2+
<manifest>
33
</manifest>

pushsdkandroid/src/main/java/com/push/android/pushsdkandroid/PushKFirebaseService.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,10 @@ open class PushKFirebaseService(
210210
val notificationConstruct = prepareNotification(remoteMessage.data, notificationId)
211211
if (notificationConstruct != null) {
212212
var isNotificationSent =
213-
pushSdkNotificationManager.sendNotification(notificationConstruct, notificationId)
213+
pushSdkNotificationManager.sendNotification(
214+
notificationConstruct,
215+
notificationId
216+
)
214217
if (isNotificationSent) {
215218
onNotificationSent(
216219
appIsInForeground,
@@ -271,7 +274,10 @@ open class PushKFirebaseService(
271274
* @return NotificationCompat.Builder?
272275
* @see PushSdkNotificationManager.NotificationStyle, (https://developer.android.com/training/notify-user/group), (https://stackoverflow.com/a/41114135)
273276
*/
274-
open fun prepareNotification(data: Map<String, String>, notificationId: Int): NotificationCompat.Builder? {
277+
open fun prepareNotification(
278+
data: Map<String, String>,
279+
notificationId: Int
280+
): NotificationCompat.Builder? {
275281
PushSDKLogger.debug(applicationContext, "calling prepareNotification()")
276282
return pushSdkNotificationManager.constructNotification(
277283
data,

0 commit comments

Comments
 (0)