-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add flutter_local_notifications module, NotiManager
- Loading branch information
djkim
committed
Jul 31, 2019
1 parent
b453224
commit 59f2d2d
Showing
4 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,41 @@ | ||
import 'package:flutter_local_notifications/flutter_local_notifications.dart'; | ||
|
||
class NotiManager { | ||
FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin; | ||
|
||
NotiManager._privateConstructor() { | ||
init(); | ||
} | ||
|
||
void init() { | ||
// initialise the plugin. app_icon needs to be a added as a drawable resource to the Android head project | ||
// If you have skipped STEP 3 then change app_icon to @mipmap/ic_launcher | ||
var initializationSettingsAndroid = | ||
new AndroidInitializationSettings('app_icon'); | ||
var initializationSettingsIOS = new IOSInitializationSettings(); | ||
var initializationSettings = new InitializationSettings( | ||
initializationSettingsAndroid, initializationSettingsIOS); | ||
_flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin(); | ||
_flutterLocalNotificationsPlugin.initialize(initializationSettings, | ||
onSelectNotification: null); | ||
} | ||
|
||
static final NotiManager instance = NotiManager._privateConstructor(); | ||
|
||
void showAlert(String message) async { | ||
var androidPlatformChannelSpecifics = new AndroidNotificationDetails( | ||
'CHANNEL_FOR_DEBUG', 'Debug', 'Notification for debug', | ||
playSound: false, importance: Importance.Max, priority: Priority.High); | ||
var iOSPlatformChannelSpecifics = | ||
new IOSNotificationDetails(presentSound: false); | ||
var platformChannelSpecifics = new NotificationDetails( | ||
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics); | ||
await _flutterLocalNotificationsPlugin.show( | ||
message.hashCode, | ||
'Debug!!', | ||
message, | ||
platformChannelSpecifics, | ||
payload: message, | ||
); | ||
} | ||
} |
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