diff --git a/.github/workflows/e2e-android.yml b/.github/workflows/e2e-android.yml index 4b5ec1ee9b..86b8a09bd7 100644 --- a/.github/workflows/e2e-android.yml +++ b/.github/workflows/e2e-android.yml @@ -2,7 +2,10 @@ name: E2E Android on: push: - paths: [packages/mobile/**, packages/backend/**, packages/state-manager/**], + paths: + - packages/mobile/** + - packages/backend/** + - packages/state-manager/** jobs: detox-android: diff --git a/.github/workflows/e2e-ios.yml b/.github/workflows/e2e-ios.yml index e9a527c994..34ad277d79 100644 --- a/.github/workflows/e2e-ios.yml +++ b/.github/workflows/e2e-ios.yml @@ -2,7 +2,10 @@ name: E2E iOS on: push: - paths: [packages/mobile/**, packages/backend/**, packages/state-manager/**], + paths: + - packages/mobile/** + - packages/backend/** + - packages/state-manager/** jobs: detox-ios: diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f4832512f..f8e8fa3c0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ [2.1.0] - unreleased +* Ask push notifications runtime permission on Android app start + * Fix for multiplicating "welcome" messages when joining a community [2.0.0] diff --git a/packages/mobile/android/app/src/main/java/com/quietmobile/MainActivity.java b/packages/mobile/android/app/src/main/java/com/quietmobile/MainActivity.java index 4670677df5..f5f696f3ca 100644 --- a/packages/mobile/android/app/src/main/java/com/quietmobile/MainActivity.java +++ b/packages/mobile/android/app/src/main/java/com/quietmobile/MainActivity.java @@ -1,10 +1,19 @@ package com.quietmobile; +import android.Manifest; import android.app.NotificationManager; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; import android.os.Bundle; +import android.util.AttributeSet; import android.util.Log; +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; import com.facebook.react.ReactActivity; @@ -110,6 +119,22 @@ protected void onCreate(Bundle savedInstanceState) { } } + @Nullable + @Override + public View onCreateView(@NonNull String name, @NonNull Context context, @NonNull AttributeSet attrs) { + checkNotificationsPermission(); + return super.onCreateView(name, context, attrs); + } + + private static final int NOTIFICATION_PERMISSION_REQUEST_CODE = 200; + + private void checkNotificationsPermission() { + if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) { + // Requesting the permission + ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.POST_NOTIFICATIONS}, NOTIFICATION_PERMISSION_REQUEST_CODE); + } + } + @Override protected void onResume() { super.onResume();