atmob_channel_reader_method_channel.dart 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import 'dart:io';
  2. import 'package:flutter/foundation.dart';
  3. import 'package:flutter/services.dart';
  4. import 'atmob_channel_reader_platform_interface.dart';
  5. /// An implementation of [AtmobChannelReaderPlatform] that uses method channels.
  6. class MethodChannelAtmobChannelReader extends AtmobChannelReaderPlatform {
  7. /// The method channel used to interact with the native platform.
  8. @visibleForTesting
  9. final methodChannel = const MethodChannel('atmob_channel_reader');
  10. @override
  11. Future<void> default4Test(String channel, int tgPlatformId, int appId) async {
  12. if (Platform.isAndroid) {
  13. await methodChannel.invokeMethod<void>('default4Test', {
  14. 'channel': channel,
  15. 'tgPlatformId': tgPlatformId,
  16. 'appId': appId,
  17. });
  18. }
  19. }
  20. @override
  21. Future<String?> getChannel() async {
  22. if (Platform.isAndroid) {
  23. return await methodChannel.invokeMethod<String>('getChannel');
  24. }
  25. if (Platform.isIOS) {
  26. return 'AppStore';
  27. }
  28. return null;
  29. }
  30. @override
  31. Future<int?> getTgPlatformId() async {
  32. if (Platform.isAndroid) {
  33. return methodChannel.invokeMethod<int>('getTgPlatformId');
  34. }
  35. return 0;
  36. }
  37. @override
  38. Future<int?> getAppId() async {
  39. if (Platform.isAndroid) {
  40. return methodChannel.invokeMethod<int>('getAppId');
  41. }
  42. return 0;
  43. }
  44. }