Skip to content

Commit

Permalink
mishmash
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-is-loading-please-wait committed Oct 28, 2024
1 parent 12fb88f commit 7d4910e
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 49 deletions.
4 changes: 2 additions & 2 deletions IOS_SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import workmanager
WorkmanagerPlugin.registerBGProcessingTask(withIdentifier: "task-identifier")

// Register a periodic task in iOS 13+
WorkmanagerPlugin.registerPeriodicTask(withIdentifier: "be.tramckrijte.workmanagerExample.iOSBackgroundAppRefresh", frequency: NSNumber(value: 20 * 60))
WorkmanagerPlugin.registerPeriodicTask(withIdentifier: "com.mishmashtech.workmanagerExample.iOSBackgroundAppRefresh", frequency: NSNumber(value: 20 * 60))
```

- Info.plist
Expand All @@ -49,7 +49,7 @@ WorkmanagerPlugin.registerPeriodicTask(withIdentifier: "be.tramckrijte.workmanag
<string>task-identifier</string>

<!-- Register a periodic task in iOS 13+ -->
<string>be.tramckrijte.workmanagerExample.iOSBackgroundAppRefresh</string>
<string>com.mishmashtech.workmanagerExample.iOSBackgroundAppRefresh</string>
</array>
```
> ⚠️ On iOS 13+, adding a `BGTaskSchedulerPermittedIdentifiers` key to the Info.plist for new `BGTaskScheduler` API disables the `performFetchWithCompletionHandler` and `setMinimumBackgroundFetchInterval`
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ To use `registerPeriodicTask` first register the task in `Info.plist` and `AppDe

```objc
// Register a periodic task with 20 minutes frequency. The frequency is in seconds.
WorkmanagerPlugin.registerPeriodicTask(withIdentifier: "be.tramckrijte.workmanagerExample.iOSBackgroundAppRefresh", frequency: NSNumber(value: 20 * 60))
WorkmanagerPlugin.registerPeriodicTask(withIdentifier: "com.mishmashtech.workmanagerExample.iOSBackgroundAppRefresh", frequency: NSNumber(value: 20 * 60))
```

Then schedule the task from your App
```dart
const iOSBackgroundAppRefresh = "be.tramckrijte.workmanagerExample.iOSBackgroundAppRefresh";
const iOSBackgroundAppRefresh = "com.mishmashtech.workmanagerExample.iOSBackgroundAppRefresh";
Workmanager().registerPeriodicTask(
iOSBackgroundAppRefresh,
iOSBackgroundAppRefresh,
Expand All @@ -161,7 +161,7 @@ iOS might terminate any running background processing tasks when the user starts
For more information see [BGProcessingTask](https://developer.apple.com/documentation/backgroundtasks/bgprocessingtask)

```dart
const iOSBackgroundProcessingTask = "be.tramckrijte.workmanagerExample.iOSBackgroundProcessingTask";
const iOSBackgroundProcessingTask = "com.mishmashtech.workmanagerExample.iOSBackgroundProcessingTask";
Workmanager().registerProcessingTask(
iOSBackgroundProcessingTask,
iOSBackgroundProcessingTask,
Expand Down
8 changes: 4 additions & 4 deletions example/integration_test/workmanager_integration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void main() {
final wm = Workmanager();
await wm.initialize(callbackDispatcher);
await wm.registerOneOffTask(
'be.tramckrijte.workmanagerExample.taskId',
'com.mishmashtech.workmanagerExample.taskId',
'taskName',
);
}, skip: !Platform.isAndroid);
Expand All @@ -30,7 +30,7 @@ void main() {
await wm.initialize(callbackDispatcher);
try {
await wm.registerOneOffTask(
'be.tramckrijte.workmanagerExample.taskId',
'com.mishmashtech.workmanagerExample.taskId',
'taskName',
);
await wm.cancelAll();
Expand Down Expand Up @@ -61,11 +61,11 @@ void main() {
await wm.initialize(callbackDispatcher);
try {
await wm.registerOneOffTask(
'be.tramckrijte.workmanagerExample.taskId',
'com.mishmashtech.workmanagerExample.taskId',
'taskName',
);
await wm.cancelByUniqueName(
'be.tramckrijte.workmanagerExample.taskId',
'com.mishmashtech.workmanagerExample.taskId',
);
} on PlatformException catch (e) {
if (e.code !=
Expand Down
6 changes: 3 additions & 3 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
PRODUCT_BUNDLE_IDENTIFIER = be.tramckrijte.workmanagerExample;
PRODUCT_BUNDLE_IDENTIFIER = com.mishmashtech.workmanagerExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
Expand Down Expand Up @@ -680,7 +680,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
PRODUCT_BUNDLE_IDENTIFIER = be.tramckrijte.workmanagerExample;
PRODUCT_BUNDLE_IDENTIFIER = com.mishmashtech.workmanagerExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand Down Expand Up @@ -712,7 +712,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
PRODUCT_BUNDLE_IDENTIFIER = be.tramckrijte.workmanagerExample;
PRODUCT_BUNDLE_IDENTIFIER = com.mishmashtech.workmanagerExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
Expand Down
10 changes: 5 additions & 5 deletions example/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ import workmanager
GeneratedPluginRegistrant.register(with: registry)
}

WorkmanagerPlugin.registerBGProcessingTask(withIdentifier: "be.tramckrijte.workmanagerExample.taskId")
WorkmanagerPlugin.registerBGProcessingTask(withIdentifier: "be.tramckrijte.workmanagerExample.rescheduledTask")
WorkmanagerPlugin.registerBGProcessingTask(withIdentifier: "be.tramckrijte.workmanagerExample.simpleDelayedTask")
WorkmanagerPlugin.registerBGProcessingTask(withIdentifier: "be.tramckrijte.workmanagerExample.iOSBackgroundProcessingTask")
WorkmanagerPlugin.registerBGProcessingTask(withIdentifier: "com.mishmashtech.workmanagerExample.taskId")
WorkmanagerPlugin.registerBGProcessingTask(withIdentifier: "com.mishmashtech.workmanagerExample.rescheduledTask")
WorkmanagerPlugin.registerBGProcessingTask(withIdentifier: "com.mishmashtech.workmanagerExample.simpleDelayedTask")
WorkmanagerPlugin.registerBGProcessingTask(withIdentifier: "com.mishmashtech.workmanagerExample.iOSBackgroundProcessingTask")

// When this task is scheduled from dart it will run with minimum 20 minute frequency. The
// frequency is not guaranteed rather iOS will schedule it as per user's App usage pattern.
// If frequency is not provided it will default to 15 minutes
WorkmanagerPlugin.registerPeriodicTask(withIdentifier: "be.tramckrijte.workmanagerExample.iOSBackgroundAppRefresh", frequency: NSNumber(value: 20 * 60))
WorkmanagerPlugin.registerPeriodicTask(withIdentifier: "com.mishmashtech.workmanagerExample.iOSBackgroundAppRefresh", frequency: NSNumber(value: 20 * 60))

return super.application(application, didFinishLaunchingWithOptions: launchOptions)

Expand Down
18 changes: 9 additions & 9 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<dict>
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
<string>be.tramckrijte.workmanagerExample.taskId</string>
<string>be.tramckrijte.workmanagerExample.simpleTask</string>
<string>be.tramckrijte.workmanagerExample.rescheduledTask</string>
<string>be.tramckrijte.workmanagerExample.failedTask</string>
<string>be.tramckrijte.workmanagerExample.simpleDelayedTask</string>
<string>be.tramckrijte.workmanagerExample.simplePeriodicTask</string>
<string>be.tramckrijte.workmanagerExample.simplePeriodic1HourTask</string>
<string>be.tramckrijte.workmanagerExample.iOSBackgroundAppRefresh</string>
<string>be.tramckrijte.workmanagerExample.iOSBackgroundProcessingTask</string>
<string>com.mishmashtech.workmanagerExample.taskId</string>
<string>com.mishmashtech.workmanagerExample.simpleTask</string>
<string>com.mishmashtech.workmanagerExample.rescheduledTask</string>
<string>com.mishmashtech.workmanagerExample.failedTask</string>
<string>com.mishmashtech.workmanagerExample.simpleDelayedTask</string>
<string>com.mishmashtech.workmanagerExample.simplePeriodicTask</string>
<string>com.mishmashtech.workmanagerExample.simplePeriodic1HourTask</string>
<string>com.mishmashtech.workmanagerExample.iOSBackgroundAppRefresh</string>
<string>com.mishmashtech.workmanagerExample.iOSBackgroundProcessingTask</string>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
Expand Down
16 changes: 8 additions & 8 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ import 'package:workmanager/workmanager.dart';

void main() => runApp(MaterialApp(home: MyApp()));

const simpleTaskKey = "be.tramckrijte.workmanagerExample.simpleTask";
const rescheduledTaskKey = "be.tramckrijte.workmanagerExample.rescheduledTask";
const failedTaskKey = "be.tramckrijte.workmanagerExample.failedTask";
const simpleDelayedTask = "be.tramckrijte.workmanagerExample.simpleDelayedTask";
const simpleTaskKey = "com.mishmashtech.workmanagerExample.simpleTask";
const rescheduledTaskKey = "com.mishmashtech.workmanagerExample.rescheduledTask";
const failedTaskKey = "com.mishmashtech.workmanagerExample.failedTask";
const simpleDelayedTask = "com.mishmashtech.workmanagerExample.simpleDelayedTask";
const simplePeriodicTask =
"be.tramckrijte.workmanagerExample.simplePeriodicTask";
"com.mishmashtech.workmanagerExample.simplePeriodicTask";
const simplePeriodic1HourTask =
"be.tramckrijte.workmanagerExample.simplePeriodic1HourTask";
"com.mishmashtech.workmanagerExample.simplePeriodic1HourTask";
const iOSBackgroundAppRefresh =
"be.tramckrijte.workmanagerExample.iOSBackgroundAppRefresh";
"com.mishmashtech.workmanagerExample.iOSBackgroundAppRefresh";
const iOSBackgroundProcessingTask =
"be.tramckrijte.workmanagerExample.iOSBackgroundProcessingTask";
"com.mishmashtech.workmanagerExample.iOSBackgroundProcessingTask";

final List<String> allTasks = [
simpleTaskKey,
Expand Down
2 changes: 1 addition & 1 deletion workmanager/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
```xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="be.tramckrijte.workmanager_example">
package="com.mishmashtech.workmanager_example">

<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ class BackgroundWorker(
companion object {
const val TAG = "BackgroundWorker"

const val PAYLOAD_KEY = "be.tramckrijte.workmanager.INPUT_DATA"
const val DART_TASK_KEY = "be.tramckrijte.workmanager.DART_TASK"
const val IS_IN_DEBUG_MODE_KEY = "be.tramckrijte.workmanager.IS_IN_DEBUG_MODE_KEY"
const val PAYLOAD_KEY = "com.mishmashtech.workmanager.INPUT_DATA"
const val DART_TASK_KEY = "com.mishmashtech.workmanager.DART_TASK"
const val IS_IN_DEBUG_MODE_KEY = "com.mishmashtech.workmanager.IS_IN_DEBUG_MODE_KEY"

const val BACKGROUND_CHANNEL_NAME =
"be.tramckrijte.workmanager/background_channel_work_manager"
"com.mishmashtech.workmanager/background_channel_work_manager"
const val BACKGROUND_CHANNEL_INITIALIZED = "backgroundChannelInitialized"

private val flutterLoader = FlutterLoader()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import android.content.Context

object SharedPreferenceHelper {
private const val SHARED_PREFS_FILE_NAME = "flutter_workmanager_plugin"
private const val CALLBACK_DISPATCHER_HANDLE_KEY = "be.tramckrijte.workmanager.CALLBACK_DISPATCHER_HANDLE_KEY"
private const val CALLBACK_DISPATCHER_HANDLE_KEY = "com.mishmashtech.workmanager.CALLBACK_DISPATCHER_HANDLE_KEY"

private fun Context.prefs() = getSharedPreferences(SHARED_PREFS_FILE_NAME, Context.MODE_PRIVATE)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class WorkmanagerPlugin : FlutterPlugin {
messenger: BinaryMessenger,
) {
workmanagerCallHandler = WorkmanagerCallHandler(context)
methodChannel = MethodChannel(messenger, "be.tramckrijte.workmanager/foreground_channel_work_manager")
methodChannel = MethodChannel(messenger, "com.mishmashtech.workmanager/foreground_channel_work_manager")
methodChannel?.setMethodCallHandler(workmanagerCallHandler)
}

Expand Down
2 changes: 1 addition & 1 deletion workmanager/ios/Classes/BackgroundWorker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class BackgroundWorker {
result(true) // Agree to Flutter's method invocation
var arguments = self.backgroundMode.onResultSendArguments
if self.inputData != "" {
arguments = arguments.merging(["be.tramckrijte.workmanager.INPUT_DATA": self.inputData]) { current, _ in current }
arguments = arguments.merging(["com.mishmashtech.workmanager.INPUT_DATA": self.inputData]) { current, _ in current }
}

backgroundMethodChannel?.invokeMethod(
Expand Down
2 changes: 1 addition & 1 deletion workmanager/ios/Classes/SwiftWorkmanagerPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extension String {
}

public class SwiftWorkmanagerPlugin: FlutterPluginAppLifeCycleDelegate {
static let identifier = "be.tramckrijte.workmanager"
static let identifier = "com.mishmashtech.workmanager"

private static var flutterPluginRegistrantCallback: FlutterPluginRegistrantCallback?

Expand Down
12 changes: 6 additions & 6 deletions workmanager/lib/src/workmanager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ class Workmanager {

static final Workmanager _instance = Workmanager._internal(
const MethodChannel(
"be.tramckrijte.workmanager/background_channel_work_manager"),
"com.mishmashtech.workmanager/background_channel_work_manager"),
const MethodChannel(
"be.tramckrijte.workmanager/foreground_channel_work_manager"));
"com.mishmashtech.workmanager/foreground_channel_work_manager"));

/// Use this constant inside your callbackDispatcher to identify when an iOS Background Fetch occurred.
///
Expand Down Expand Up @@ -127,19 +127,19 @@ class Workmanager {
static bool _isInDebugMode = false;

MethodChannel _backgroundChannel = const MethodChannel(
"be.tramckrijte.workmanager/background_channel_work_manager");
"com.mishmashtech.workmanager/background_channel_work_manager");
MethodChannel _foregroundChannel = const MethodChannel(
"be.tramckrijte.workmanager/foreground_channel_work_manager");
"com.mishmashtech.workmanager/foreground_channel_work_manager");

/// A helper function so you only need to implement a [BackgroundTaskHandler]
void executeTask(final BackgroundTaskHandler backgroundTask) {
WidgetsFlutterBinding.ensureInitialized();
DartPluginRegistrant.ensureInitialized();

_backgroundChannel.setMethodCallHandler((call) async {
final inputData = call.arguments["be.tramckrijte.workmanager.INPUT_DATA"];
final inputData = call.arguments["com.mishmashtech.workmanager.INPUT_DATA"];
return backgroundTask(
call.arguments["be.tramckrijte.workmanager.DART_TASK"],
call.arguments["com.mishmashtech.workmanager.DART_TASK"],
inputData == null ? null : jsonDecode(inputData),
);
});
Expand Down

0 comments on commit 7d4910e

Please sign in to comment.