Skip to content

Commit

Permalink
Fix README broken code, add info about qt-сompatibility and permission.
Browse files Browse the repository at this point in the history
  • Loading branch information
mozerrr committed Oct 20, 2023
1 parent c3c5b08 commit 5412561
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
4 changes: 4 additions & 0 deletions packages/aurora_push_service/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.0+1

* Fix README broken code, add info about qt-сompatibility and permission.

## 0.2.0

* Initial Open Source release.
38 changes: 34 additions & 4 deletions packages/aurora_push_service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,50 @@
Сервис для получения пуш уведомлений от Aurora OS.

## Getting Started
Для начала необходимо добавить QT-совместимость в main.cpp вашего приложения.

Сначала добавьте новый `include`.
```c++
#include <flutter/compatibility.h>
```

Затем добавьте `EnableQtCompatibility()` в вашу `main` функцию.
```c++
int main(int argc, char *argv[])
{
Application::Initialize(argc, argv);
EnableQtCompatibility(); // Включение "поддержки Qt" для плагинов
RegisterPlugins();
Application::Launch();
return 0;
}
```
Также необходимо добавить разрешение на push-уведомления.
Для этого по пути `aurora/desktop/` в файле `YOUR_APP_NAME.desktop`
добавьте в Permissions `PushNotifications`.
```desktop
[X-Application]
Permissions=PushNotifications;Internet
```

После этого можно использовать Flutter плагин.
```dart
// Call after WidgetsFlutterBinding.ensureInitialized();
final auroraPushPlugin = const AuroraPushPlugin();
final auroraPushService = const AuroraPushService();
final notificationPlugin = FlutterLocalNotificationsPlugin();
final registrationId = await auroraPushPlugin.initialize(
// Шаг 1: Инициализируйте AuroraPushService.
final registrationId = await auroraPushService.initialize(
// TODO: Add your applicationId from Aurora Center
applicationId: '',
);
// ···
// Send registrationId to your backend and send push message from it.
// Шаг 2: Сохраните registrationId, по нему вы будете
// отправлять пуш уведомления этому устройству.
// ···
// Шаг 3: Слушайте onMessage stream.
final messagesSubscription =
auroraPushPlugin.onMessage.listen((event) async {
auroraPushService.onMessage.listen((event) async {
await notificationPlugin.show(
0,
event.title,
Expand Down
2 changes: 1 addition & 1 deletion packages/aurora_push_service/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: aurora_push_service
description: A new Flutter plugin project for Aurora OS to get Push Messages.
version: 0.2.0
version: 0.2.0+1
publish_to: https://pub-aurora.friflex.com
homepage: "https://github.com/smmarty/aurora_flutter/tree/main/packages/aurora_push_service"

Expand Down

0 comments on commit 5412561

Please sign in to comment.