Skip to content

Commit

Permalink
chore: add usage of getInitialMessage in Example
Browse files Browse the repository at this point in the history
WIP
  • Loading branch information
esarbanis committed Feb 16, 2022
1 parent b7f609f commit 6a277f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
android:exported="true">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
Expand Down
13 changes: 10 additions & 3 deletions packages/pusher_beams/example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import 'package:pusher_beams/pusher_beams.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();

await PusherBeams.instance
.start('your-instance-id'); // Supply your own instanceId
await PusherBeams.instance.start(
'your-instance-id'); // Supply your own instanceId

runApp(const MyApp());
}
Expand Down Expand Up @@ -70,6 +69,14 @@ class _MyHomePageState extends State<MyHomePage> {
await PusherBeams.instance
.onMessageReceivedInTheForeground(_onMessageReceivedInTheForeground);
}
await _checkForInitialMessage();
}

Future<void> _checkForInitialMessage() async {
final initialMessage = await PusherBeams.instance.getInitialMessage();
if (initialMessage != null) {
_showAlert('Initial Message Is:', initialMessage.toString());
}
}

void _onMessageReceivedInTheForeground(Map<Object?, Object?> data) {
Expand Down

0 comments on commit 6a277f4

Please sign in to comment.