Skip to content

Commit

Permalink
Disable pendingTransition of PermissionActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
minhyeok4dev committed Jun 24, 2023
1 parent 957c91b commit 2e7328a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion FlareLane/src/main/java/com/flarelane/FlareLane.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public class FlareLane {
public static class SdkInfo {
public static SdkType type = SdkType.NATIVE;
public static String version = "1.3.0";
public static String version = "1.3.1";
}

protected static com.flarelane.NotificationConvertedHandler notificationConvertedHandler = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions,
}

finish();
overridePendingTransition(0, 0);
}
}
30 changes: 30 additions & 0 deletions app/src/main/java/com/flarelane/example/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

askNotificationPermission();
FirebaseMessaging.getInstance().getToken()
.addOnCompleteListener(new OnCompleteListener<String>() {
@Override
Expand Down Expand Up @@ -114,4 +115,33 @@ public void onClick(View v) {
}
});
}

// FOR FIREBASE: https://firebase.google.com/docs/cloud-messaging/android/client
// Declare the launcher at the top of your Activity/Fragment:
private final ActivityResultLauncher<String> requestPermissionLauncher =
registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> {
if (isGranted) {
// FCM SDK (and your app) can post notifications.
} else {
// TODO: Inform user that that your app will not show notifications.
}
});

private void askNotificationPermission() {
// This is only necessary for API level >= 33 (TIRAMISU)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) ==
PackageManager.PERMISSION_GRANTED) {
// FCM SDK (and your app) can post notifications.
} else if (shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS)) {
// TODO: display an educational UI explaining to the user the features that will be enabled
// by them granting the POST_NOTIFICATION permission. This UI should provide the user
// "OK" and "No thanks" buttons. If the user selects "OK," directly request the permission.
// If the user selects "No thanks," allow the user to continue without notifications.
} else {
// Directly ask for the permission
requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS);
}
}
}
}

0 comments on commit 2e7328a

Please sign in to comment.