Skip to content

Commit

Permalink
Merge pull request #57395 from software-mansion-labs/fix/background-t…
Browse files Browse the repository at this point in the history
…ask-build-app

[NoQA] Fix build for `RNBackgroundTaskModule` and unsubscribe from Broadcast receiver task
  • Loading branch information
mountiny authored Mar 2, 2025
2 parents 996eecc + 989f590 commit 7788727
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ class ReactNativeBackgroundTaskModule internal constructor(context: ReactApplica
return NAME
}

override fun invalidate() {
super.invalidate()
try {
reactApplicationContext.unregisterReceiver(taskReceiver)
Log.d("ReactNativeBackgroundTaskModule", "BroadcastReceiver unregistered")
} catch (e: IllegalArgumentException) {
Log.w("ReactNativeBackgroundTaskModule", "Receiver not registered or already unregistered")
}
}

@ReactMethod
override fun defineTask(taskName: String, taskExecutor: Callback, promise: Promise) {
try {
Expand Down
2 changes: 1 addition & 1 deletion modules/background-task/ios/ReactNativeBackgroundTask.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifdef RCT_NEW_ARCH_ENABLED
#import "RNReactNativeBackgroundTaskSpec.h"
#import <ReactCodegen/RNReactNativeBackgroundTaskSpec/RNReactNativeBackgroundTaskSpec.h>
#import <BackgroundTasks/BackgroundTasks.h>

@interface ReactNativeBackgroundTask : NativeReactNativeBackgroundTaskSpecBase <NativeReactNativeBackgroundTaskSpec>
Expand Down

0 comments on commit 7788727

Please sign in to comment.