fix(repo): Remove notification examples
This commit is contained in:
parent
f2b140de18
commit
fe07b2a488
@ -1,11 +1,9 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:math';
|
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:moxplatform/moxplatform.dart';
|
import 'package:moxplatform/moxplatform.dart';
|
||||||
import 'package:path/path.dart';
|
import 'package:path/path.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
|
||||||
|
|
||||||
/// The id of the notification channel.
|
/// The id of the notification channel.
|
||||||
const channelId = "me.polynom.moxplatform.testing3";
|
const channelId = "me.polynom.moxplatform.testing3";
|
||||||
@ -31,54 +29,6 @@ class MyApp extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MyAppState extends State<MyApp> {
|
class MyAppState extends State<MyApp> {
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
|
|
||||||
initStateAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> initStateAsync() async {
|
|
||||||
await Permission.notification.request();
|
|
||||||
|
|
||||||
await MoxplatformPlugin.notifications.createNotificationChannels(
|
|
||||||
[
|
|
||||||
NotificationChannel(
|
|
||||||
id: channelId,
|
|
||||||
title: "Test1",
|
|
||||||
description: "Test notification channel",
|
|
||||||
importance: NotificationChannelImportance.MIN,
|
|
||||||
showBadge: true,
|
|
||||||
vibration: false,
|
|
||||||
enableLights: false,
|
|
||||||
),
|
|
||||||
NotificationChannel(
|
|
||||||
id: otherChannelId,
|
|
||||||
title: "Test2",
|
|
||||||
description: "Test notification channel for warnings",
|
|
||||||
importance: NotificationChannelImportance.MIN,
|
|
||||||
showBadge: true,
|
|
||||||
vibration: false,
|
|
||||||
enableLights: false,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
await MoxplatformPlugin.notifications.setI18n(
|
|
||||||
NotificationI18nData(
|
|
||||||
reply: "答える",
|
|
||||||
markAsRead: "読みた",
|
|
||||||
you: "あなた",
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
MoxplatformPlugin.notifications.getEventStream().listen((event) {
|
|
||||||
// ignore: avoid_print
|
|
||||||
print(
|
|
||||||
'NotificationEvent(type: ${event.type}, jid: ${event.jid}, payload: ${event.payload}, extras: ${event.extra})',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
@ -106,10 +56,6 @@ class MyHomePageState extends State<MyHomePage> {
|
|||||||
Sender('Raiden Shogun', 'raiden@tevhat'),
|
Sender('Raiden Shogun', 'raiden@tevhat'),
|
||||||
];
|
];
|
||||||
|
|
||||||
/// List of sent messages.
|
|
||||||
List<NotificationMessage> messages =
|
|
||||||
List<NotificationMessage>.empty(growable: true);
|
|
||||||
|
|
||||||
Future<void> _cryptoTest() async {
|
Future<void> _cryptoTest() async {
|
||||||
final result = await FilePicker.platform.pickFiles();
|
final result = await FilePicker.platform.pickFiles();
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
@ -187,87 +133,6 @@ class MyHomePageState extends State<MyHomePage> {
|
|||||||
},
|
},
|
||||||
child: const Text('Test recordSentMessage (notes fallback)'),
|
child: const Text('Test recordSentMessage (notes fallback)'),
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () async {
|
|
||||||
final result = await FilePicker.platform.pickFiles(
|
|
||||||
type: FileType.image,
|
|
||||||
);
|
|
||||||
// ignore: avoid_print
|
|
||||||
print('Picked file: ${result?.files.single.path}');
|
|
||||||
|
|
||||||
// Create a new message.
|
|
||||||
final senderIndex = Random().nextInt(senders.length);
|
|
||||||
final time = DateTime.now().millisecondsSinceEpoch;
|
|
||||||
messages.add(NotificationMessage(
|
|
||||||
jid: senders[senderIndex].jid,
|
|
||||||
sender: senders[senderIndex].name,
|
|
||||||
content: NotificationMessageContent(
|
|
||||||
body: result != null ? null : 'Message #${messages.length}',
|
|
||||||
mime: 'image/jpeg',
|
|
||||||
path: result?.files.single.path,
|
|
||||||
),
|
|
||||||
timestamp: time,
|
|
||||||
));
|
|
||||||
|
|
||||||
await Future<void>.delayed(const Duration(seconds: 4));
|
|
||||||
await MoxplatformPlugin.notifications.showMessagingNotification(
|
|
||||||
MessagingNotification(
|
|
||||||
id: 2343,
|
|
||||||
title: 'Test conversation',
|
|
||||||
messages: messages,
|
|
||||||
channelId: channelId,
|
|
||||||
jid: 'testjid',
|
|
||||||
isGroupchat: true,
|
|
||||||
extra: {
|
|
||||||
'jid': 'testjid',
|
|
||||||
'avatarPath': 'lol',
|
|
||||||
'rio': 'cute',
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: const Text('Show messaging notification'),
|
|
||||||
),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () {
|
|
||||||
MoxplatformPlugin.notifications.showNotification(
|
|
||||||
RegularNotification(
|
|
||||||
id: 4384,
|
|
||||||
title: 'Warning',
|
|
||||||
body: 'Something brokey',
|
|
||||||
channelId: otherChannelId,
|
|
||||||
icon: NotificationIcon.warning,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: const Text('Show warning notification'),
|
|
||||||
),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () {
|
|
||||||
MoxplatformPlugin.notifications.showNotification(
|
|
||||||
RegularNotification(
|
|
||||||
id: 4384,
|
|
||||||
title: 'Error',
|
|
||||||
body: "Lol, you're on your own",
|
|
||||||
channelId: otherChannelId,
|
|
||||||
icon: NotificationIcon.error,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: const Text('Show error notification'),
|
|
||||||
),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () async {
|
|
||||||
final result = await FilePicker.platform.pickFiles(
|
|
||||||
type: FileType.image,
|
|
||||||
);
|
|
||||||
if (result == null) return;
|
|
||||||
|
|
||||||
MoxplatformPlugin.notifications
|
|
||||||
.setNotificationSelfAvatar(result.files.single.path!);
|
|
||||||
},
|
|
||||||
child: const Text('Set notification self-avatar'),
|
|
||||||
),
|
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
// ignore: avoid_print
|
// ignore: avoid_print
|
||||||
|
@ -41,8 +41,6 @@ dependencies:
|
|||||||
|
|
||||||
path: 1.8.3
|
path: 1.8.3
|
||||||
|
|
||||||
permission_handler: 10.4.3
|
|
||||||
|
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
cupertino_icons: ^1.0.2
|
cupertino_icons: ^1.0.2
|
||||||
|
@ -82,10 +82,10 @@ class MoxplatformApi {
|
|||||||
/// Platform APIs
|
/// Platform APIs
|
||||||
Future<String> getPersistentDataPath() async {
|
Future<String> getPersistentDataPath() async {
|
||||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||||
'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.getPersistentDataPath', codec,
|
'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.getPersistentDataPath',
|
||||||
|
codec,
|
||||||
binaryMessenger: _binaryMessenger);
|
binaryMessenger: _binaryMessenger);
|
||||||
final List<Object?>? replyList =
|
final List<Object?>? replyList = await channel.send(null) as List<Object?>?;
|
||||||
await channel.send(null) as List<Object?>?;
|
|
||||||
if (replyList == null) {
|
if (replyList == null) {
|
||||||
throw PlatformException(
|
throw PlatformException(
|
||||||
code: 'channel-error',
|
code: 'channel-error',
|
||||||
@ -109,10 +109,10 @@ class MoxplatformApi {
|
|||||||
|
|
||||||
Future<String> getCacheDataPath() async {
|
Future<String> getCacheDataPath() async {
|
||||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||||
'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.getCacheDataPath', codec,
|
'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.getCacheDataPath',
|
||||||
|
codec,
|
||||||
binaryMessenger: _binaryMessenger);
|
binaryMessenger: _binaryMessenger);
|
||||||
final List<Object?>? replyList =
|
final List<Object?>? replyList = await channel.send(null) as List<Object?>?;
|
||||||
await channel.send(null) as List<Object?>?;
|
|
||||||
if (replyList == null) {
|
if (replyList == null) {
|
||||||
throw PlatformException(
|
throw PlatformException(
|
||||||
code: 'channel-error',
|
code: 'channel-error',
|
||||||
@ -136,10 +136,10 @@ class MoxplatformApi {
|
|||||||
|
|
||||||
Future<void> openBatteryOptimisationSettings() async {
|
Future<void> openBatteryOptimisationSettings() async {
|
||||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||||
'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.openBatteryOptimisationSettings', codec,
|
'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.openBatteryOptimisationSettings',
|
||||||
|
codec,
|
||||||
binaryMessenger: _binaryMessenger);
|
binaryMessenger: _binaryMessenger);
|
||||||
final List<Object?>? replyList =
|
final List<Object?>? replyList = await channel.send(null) as List<Object?>?;
|
||||||
await channel.send(null) as List<Object?>?;
|
|
||||||
if (replyList == null) {
|
if (replyList == null) {
|
||||||
throw PlatformException(
|
throw PlatformException(
|
||||||
code: 'channel-error',
|
code: 'channel-error',
|
||||||
@ -158,10 +158,10 @@ class MoxplatformApi {
|
|||||||
|
|
||||||
Future<bool> isIgnoringBatteryOptimizations() async {
|
Future<bool> isIgnoringBatteryOptimizations() async {
|
||||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||||
'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.isIgnoringBatteryOptimizations', codec,
|
'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.isIgnoringBatteryOptimizations',
|
||||||
|
codec,
|
||||||
binaryMessenger: _binaryMessenger);
|
binaryMessenger: _binaryMessenger);
|
||||||
final List<Object?>? replyList =
|
final List<Object?>? replyList = await channel.send(null) as List<Object?>?;
|
||||||
await channel.send(null) as List<Object?>?;
|
|
||||||
if (replyList == null) {
|
if (replyList == null) {
|
||||||
throw PlatformException(
|
throw PlatformException(
|
||||||
code: 'channel-error',
|
code: 'channel-error',
|
||||||
@ -184,12 +184,18 @@ class MoxplatformApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Contacts APIs
|
/// Contacts APIs
|
||||||
Future<void> recordSentMessage(String arg_name, String arg_jid, String? arg_avatarPath, FallbackIconType arg_fallbackIcon) async {
|
Future<void> recordSentMessage(String arg_name, String arg_jid,
|
||||||
|
String? arg_avatarPath, FallbackIconType arg_fallbackIcon) async {
|
||||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||||
'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.recordSentMessage', codec,
|
'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.recordSentMessage',
|
||||||
|
codec,
|
||||||
binaryMessenger: _binaryMessenger);
|
binaryMessenger: _binaryMessenger);
|
||||||
final List<Object?>? replyList =
|
final List<Object?>? replyList = await channel.send(<Object?>[
|
||||||
await channel.send(<Object?>[arg_name, arg_jid, arg_avatarPath, arg_fallbackIcon.index]) as List<Object?>?;
|
arg_name,
|
||||||
|
arg_jid,
|
||||||
|
arg_avatarPath,
|
||||||
|
arg_fallbackIcon.index
|
||||||
|
]) as List<Object?>?;
|
||||||
if (replyList == null) {
|
if (replyList == null) {
|
||||||
throw PlatformException(
|
throw PlatformException(
|
||||||
code: 'channel-error',
|
code: 'channel-error',
|
||||||
@ -207,12 +213,25 @@ class MoxplatformApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Cryptography APIs
|
/// Cryptography APIs
|
||||||
Future<CryptographyResult?> encryptFile(String arg_sourcePath, String arg_destPath, Uint8List arg_key, Uint8List arg_iv, CipherAlgorithm arg_algorithm, String arg_hashSpec) async {
|
Future<CryptographyResult?> encryptFile(
|
||||||
|
String arg_sourcePath,
|
||||||
|
String arg_destPath,
|
||||||
|
Uint8List arg_key,
|
||||||
|
Uint8List arg_iv,
|
||||||
|
CipherAlgorithm arg_algorithm,
|
||||||
|
String arg_hashSpec) async {
|
||||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||||
'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.encryptFile', codec,
|
'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.encryptFile',
|
||||||
|
codec,
|
||||||
binaryMessenger: _binaryMessenger);
|
binaryMessenger: _binaryMessenger);
|
||||||
final List<Object?>? replyList =
|
final List<Object?>? replyList = await channel.send(<Object?>[
|
||||||
await channel.send(<Object?>[arg_sourcePath, arg_destPath, arg_key, arg_iv, arg_algorithm.index, arg_hashSpec]) as List<Object?>?;
|
arg_sourcePath,
|
||||||
|
arg_destPath,
|
||||||
|
arg_key,
|
||||||
|
arg_iv,
|
||||||
|
arg_algorithm.index,
|
||||||
|
arg_hashSpec
|
||||||
|
]) as List<Object?>?;
|
||||||
if (replyList == null) {
|
if (replyList == null) {
|
||||||
throw PlatformException(
|
throw PlatformException(
|
||||||
code: 'channel-error',
|
code: 'channel-error',
|
||||||
@ -229,12 +248,25 @@ class MoxplatformApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<CryptographyResult?> decryptFile(String arg_sourcePath, String arg_destPath, Uint8List arg_key, Uint8List arg_iv, CipherAlgorithm arg_algorithm, String arg_hashSpec) async {
|
Future<CryptographyResult?> decryptFile(
|
||||||
|
String arg_sourcePath,
|
||||||
|
String arg_destPath,
|
||||||
|
Uint8List arg_key,
|
||||||
|
Uint8List arg_iv,
|
||||||
|
CipherAlgorithm arg_algorithm,
|
||||||
|
String arg_hashSpec) async {
|
||||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||||
'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.decryptFile', codec,
|
'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.decryptFile',
|
||||||
|
codec,
|
||||||
binaryMessenger: _binaryMessenger);
|
binaryMessenger: _binaryMessenger);
|
||||||
final List<Object?>? replyList =
|
final List<Object?>? replyList = await channel.send(<Object?>[
|
||||||
await channel.send(<Object?>[arg_sourcePath, arg_destPath, arg_key, arg_iv, arg_algorithm.index, arg_hashSpec]) as List<Object?>?;
|
arg_sourcePath,
|
||||||
|
arg_destPath,
|
||||||
|
arg_key,
|
||||||
|
arg_iv,
|
||||||
|
arg_algorithm.index,
|
||||||
|
arg_hashSpec
|
||||||
|
]) as List<Object?>?;
|
||||||
if (replyList == null) {
|
if (replyList == null) {
|
||||||
throw PlatformException(
|
throw PlatformException(
|
||||||
code: 'channel-error',
|
code: 'channel-error',
|
||||||
@ -251,12 +283,14 @@ class MoxplatformApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Uint8List?> hashFile(String arg_sourcePath, String arg_hashSpec) async {
|
Future<Uint8List?> hashFile(
|
||||||
|
String arg_sourcePath, String arg_hashSpec) async {
|
||||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||||
'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.hashFile', codec,
|
'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.hashFile',
|
||||||
|
codec,
|
||||||
binaryMessenger: _binaryMessenger);
|
binaryMessenger: _binaryMessenger);
|
||||||
final List<Object?>? replyList =
|
final List<Object?>? replyList = await channel
|
||||||
await channel.send(<Object?>[arg_sourcePath, arg_hashSpec]) as List<Object?>?;
|
.send(<Object?>[arg_sourcePath, arg_hashSpec]) as List<Object?>?;
|
||||||
if (replyList == null) {
|
if (replyList == null) {
|
||||||
throw PlatformException(
|
throw PlatformException(
|
||||||
code: 'channel-error',
|
code: 'channel-error',
|
||||||
@ -274,12 +308,14 @@ class MoxplatformApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Media APIs
|
/// Media APIs
|
||||||
Future<bool> generateVideoThumbnail(String arg_src, String arg_dest, int arg_maxWidth) async {
|
Future<bool> generateVideoThumbnail(
|
||||||
|
String arg_src, String arg_dest, int arg_maxWidth) async {
|
||||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||||
'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.generateVideoThumbnail', codec,
|
'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.generateVideoThumbnail',
|
||||||
|
codec,
|
||||||
binaryMessenger: _binaryMessenger);
|
binaryMessenger: _binaryMessenger);
|
||||||
final List<Object?>? replyList =
|
final List<Object?>? replyList = await channel
|
||||||
await channel.send(<Object?>[arg_src, arg_dest, arg_maxWidth]) as List<Object?>?;
|
.send(<Object?>[arg_src, arg_dest, arg_maxWidth]) as List<Object?>?;
|
||||||
if (replyList == null) {
|
if (replyList == null) {
|
||||||
throw PlatformException(
|
throw PlatformException(
|
||||||
code: 'channel-error',
|
code: 'channel-error',
|
||||||
|
Reference in New Issue
Block a user