Skip to content

Commit

Permalink
[AND-209] Update stream-android-push to v1.3.0 and update related dep…
Browse files Browse the repository at this point in the history
…endencies. (#5573)

* [AND-209] Update stream-push-android to v1.3.0 and update related dependencies.

* [AND-209] Update CHANGELOG.md.

---------

Co-authored-by: PetarVelikov <[email protected]>
  • Loading branch information
VelikovPetar and PetarVelikov authored Jan 22, 2025
1 parent dca0dc0 commit 879f0fa
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 28 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
### 🐞 Fixed

### ⬆️ Improved
- Update compileSdk to 35 (#5573)[https://github.com/GetStream/stream-chat-android/pull/5573]
- Update dependency versions:
- AndroidX Ktx 1.15.0 (#5573)[https://github.com/GetStream/stream-chat-android/pull/5573]
- Stream Push 1.3.0 (#5573)[https://github.com/GetStream/stream-chat-android/pull/5573]

### ✅ Added

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.getstream.chat.android

object Configuration {
const val compileSdk = 34
const val compileSdk = 35
const val targetSdk = 34
const val sampleTargetSdk = 34
const val minSdk = 21
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ androidxComposeMaterial3 = "1.3.1"
androidxComposeMaterial3Adaptive = "1.0.0"
androidxCoreTest = "2.2.0"
androidxFragment = "1.8.5"
androidxKtx = "1.13.1"
androidxKtx = "1.15.0"
androidxLifecycle = "2.8.7"
androidxNavigation = "2.8.4"
androidxPreferences = "1.2.1"
Expand Down Expand Up @@ -79,7 +79,7 @@ shot = "6.1.0"
sonarqube = "6.0.1.5171"
spotless = "6.20.0"
streamLog = "1.3.1"
streamPush = "1.1.9"
streamPush = "1.3.0"
streamResult = "1.3.2"
testParameterInjector = "1.12"
threetenbp = "1.7.0"
Expand Down
2 changes: 1 addition & 1 deletion stream-chat-android-client/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<application>

<provider
android:name="io.getstream.android.push.delegate.PushDelegateProvider"
android:name="io.getstream.android.push.delegate.AndroidPushDelegateProvider"
android:authorities="${applicationId}.io.getstream.android.push"
android:exported="false"
tools:node="merge"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ internal class ChatNotificationsImpl constructor(
permissionManager
.takeIf { notificationConfig.requestPermissionOnAppLaunch() }
?.start()
notificationConfig.pushDeviceGenerators.firstOrNull { it.isValidForThisDevice(context) }
notificationConfig.pushDeviceGenerators.firstOrNull { it.isValidForThisDevice() }
?.let {
it.onPushDeviceGeneratorSelected()
it.asyncGeneratePushDevice { setDevice(it.toDevice()) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package io.getstream.chat.android.client.notifications

import android.content.Context
import io.getstream.android.push.PushDevice
import io.getstream.android.push.PushProvider
import io.getstream.android.push.delegate.PushDelegate
Expand All @@ -30,10 +29,9 @@ private typealias DevicePushProvider = io.getstream.chat.android.models.PushProv
/**
* Internal class that handle PN stuff.
* It is declared in our Android Manifest and is used by reflection.
*
*/
@Suppress("Unused")
internal class ChatPushDelegate(context: Context) : PushDelegate(context) {
internal class ChatPushDelegate : PushDelegate() {

private val expectedKeys = hashSetOf(KEY_CHANNEL_ID, KEY_MESSAGE_ID, KEY_CHANNEL_TYPE, KEY_GETSTREAM)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ object ChatHelper {
fun initializeSdk(context: Context, apiKey: String, baseUrl: String? = null) {
Log.d(TAG, "[init] apiKey: $apiKey")
val notificationConfig = NotificationConfig(
pushDeviceGenerators = listOf(FirebasePushDeviceGenerator(providerName = "Firebase")),
pushDeviceGenerators = listOf(
FirebasePushDeviceGenerator(
context = context,
providerName = "Firebase",
),
),
autoTranslationEnabled = ChatApp.autoTranslationEnabled,
)
val notificationHandler = NotificationHandlerFactory.createNotificationHandler(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import androidx.annotation.NonNull;
import androidx.core.app.NotificationCompat;

import com.google.firebase.messaging.FirebaseMessaging;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import com.huawei.hms.push.HmsMessageService;
Expand Down Expand Up @@ -178,7 +179,9 @@ public void configureFirebaseNotifications(Context context) {
boolean ignorePushMessagesWhenUserOnline = true;
List<PushDeviceGenerator> pushDeviceGeneratorList = Collections.singletonList(
new FirebasePushDeviceGenerator(
"providerName"
FirebaseMessaging.getInstance(),
"providerName",
context
)
);
NotificationConfig notificationConfig = new NotificationConfig(pushNotificationEnabled, ignorePushMessagesWhenUserOnline, pushDeviceGeneratorList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,12 @@ class Push {
*/
fun configureFirebaseNotifications(context: Context) {
val notificationConfig = NotificationConfig(
pushDeviceGenerators = listOf(FirebasePushDeviceGenerator(providerName = "providerName")),
pushDeviceGenerators = listOf(
FirebasePushDeviceGenerator(
context = context,
providerName = "providerName"
)
),
)
ChatClient.Builder("apiKey", context)
.notifications(notificationConfig)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ public fun Context.isPermissionDeclared(permission: String): Boolean {
return packageManager
.getPackageInfo(packageName, PackageManager.GET_PERMISSIONS)
.requestedPermissions
.contains(permission)
?.contains(permission) == true
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ class ChatInitializer(
val notificationConfig =
NotificationConfig(
pushDeviceGenerators = listOf(
FirebasePushDeviceGenerator(providerName = "Firebase"),
FirebasePushDeviceGenerator(
context = context,
providerName = "Firebase",
),
HuaweiPushDeviceGenerator(
context = context,
appId = ApplicationConfigurator.HUAWEI_APP_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import com.permissionx.guolindev.PermissionX
import io.getstream.chat.android.core.internal.InternalStreamChatApi
import io.getstream.chat.android.ui.common.R
import io.getstream.chat.android.ui.common.permissions.Permissions
import io.getstream.chat.android.ui.common.utils.isPermissionDeclared
import io.getstream.chat.android.ui.utils.extensions.activity
import io.getstream.chat.android.ui.utils.extensions.dpToPxPrecise
import io.getstream.chat.android.uiutils.util.openSystemSettings
Expand Down Expand Up @@ -57,7 +58,7 @@ public class PermissionChecker {
* False in another case
*/
public fun isNeededToRequestForCameraPermissions(context: Context): Boolean =
isPermissionContainedOnManifest(context, Manifest.permission.CAMERA) && !isGrantedCameraPermissions(context)
context.isPermissionDeclared(Manifest.permission.CAMERA) && !isGrantedCameraPermissions(context)

/**
* Requests the correct visual media permissions (image/video) based on the device's API level.
Expand Down Expand Up @@ -197,20 +198,6 @@ public class PermissionChecker {
)
}

/**
* Check if the [permission] was declared on the App Manifest
*
* @param context of the current Application
* @param permission name to be checked
*
* @return True if the permission is present on the App Manifest
*/
private fun isPermissionContainedOnManifest(context: Context, permission: String): Boolean =
context.packageManager
.getPackageInfo(context.packageName, PackageManager.GET_PERMISSIONS)
.requestedPermissions
.contains(permission)

@Suppress("LongParameterList")
private fun checkPermissions(
view: View,
Expand Down

0 comments on commit 879f0fa

Please sign in to comment.