-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #110 from rollbar/native_hook
Initialize the native Rollbar/Android SDK as a hook instead of explicitly
- Loading branch information
Showing
4 changed files
with
59 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import 'package:flutter/services.dart'; | ||
import 'package:rollbar_dart/rollbar.dart'; | ||
|
||
import '../method_channel.dart'; | ||
import 'hook.dart'; | ||
|
||
class NativeHook implements Hook { | ||
static const _platform = MethodChannel('com.rollbar.flutter'); | ||
|
||
@override | ||
Future<void> install(final Config config) async { | ||
await _platform.initialize(config: config); | ||
} | ||
|
||
@override | ||
Future<void> uninstall() async { | ||
await _platform.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import 'package:flutter/services.dart'; | ||
import 'package:rollbar_flutter/rollbar_flutter.dart'; | ||
|
||
extension RollbarMethodChannel on MethodChannel { | ||
/// The platform-specific path where we can persist data if needed. | ||
Future<String> get persistencePath async => | ||
await invokeMethod('persistencePath'); | ||
|
||
/// Initializes the native Apple/Android SDK Rollbar notifier | ||
/// using the given configuration. | ||
Future<void> initialize({required Config config}) async => | ||
await invokeMethod('initialize', config.toMap()); | ||
|
||
/// Unwinds the native Apple/Android SDK Rollbar notifier. | ||
/// | ||
/// This is a no-op at the moment. | ||
Future<void> close() async => await invokeMethod('close'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters