Skip to content

Instantly share code, notes, and snippets.

View iamcalledrob's full-sized avatar

Rob Mason iamcalledrob

View GitHub Profile
@iamcalledrob
iamcalledrob / CaptureComposable.kt
Last active October 31, 2024 17:43
Android headless composable capture
import android.app.Presentation
import android.content.Context
import android.graphics.Bitmap
import android.graphics.Picture
import android.graphics.SurfaceTexture
import android.hardware.display.DisplayManager
import android.view.Display
import android.view.Surface
import android.view.ViewGroup
import androidx.compose.foundation.layout.Box
@iamcalledrob
iamcalledrob / UNUserNotificationCenter+Async.swift
Created May 16, 2023 16:48
Fix for UNUserNotificationCenter.removeDeliveredNotifications not actually removing notifications
extension UNUserNotificationCenter {
func removeDeliveredNotificationsAsync(withIdentifiers identifiers: [String]) async {
// Calls to `UNUserNotificationCenter.current().removeDeliveredNotifications` schedule work
// on a background thread, with no completion handler or async/await interface. There is no
// way to know whether the work completed or not. If the notification service extension exits
// before the work has been completed, the work is cancelled and notifications are not removed.
//
// This is really poor API design on Apple's part, and even poorer documentation
//
// https://stackoverflow.com/questions/54565979#comment104110958_54680225