diff --git a/lib/pages/onboard.dart b/lib/pages/onboard.dart index 7fd6b57..f46ebb1 100644 --- a/lib/pages/onboard.dart +++ b/lib/pages/onboard.dart @@ -1,7 +1,7 @@ // ignore_for_file: avoid_web_libraries_in_flutter import 'dart:convert'; - +import 'dart:js' as js; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; @@ -444,6 +444,7 @@ class _OnboardState extends State { // js.context.callMethod("saveData", // ["timetable", jsonEncode(compressedTimetable)]); if (!mounted) return; + js.context.callMethod("openPopup"); Navigator.pushReplacementNamed(context, "/home"); } } diff --git a/web/index.html b/web/index.html index 55b728d..e8bcc7b 100644 --- a/web/index.html +++ b/web/index.html @@ -44,9 +44,33 @@ OneSignalDeferred.push(function (OneSignal) { OneSignal.init({ appId: "d43f4e31-c574-4639-b7e6-76ae0e24b8d2", + notifyButton: { + enable: true + }, + promptOptions: { + slidedown: { + prompts: [ + { + type: "push", // current types are "push" & "category" + autoPrompt: false, + text: { + /* limited to 90 characters */ + actionMessage: "We'd like to show you notifications for the latest news and updates.", + /* acceptButton limited to 15 characters */ + acceptButton: "Allow", + /* cancelButton limited to 15 characters */ + cancelButton: "Cancel" + }, + } + ] + } + }, + serviceWorkerParam: { scope: "/" }, + serviceWorkerPath: "/OneSignalSDKWorker.js", }); }); + diff --git a/web/open_popup.js b/web/open_popup.js new file mode 100644 index 0000000..1734071 --- /dev/null +++ b/web/open_popup.js @@ -0,0 +1,3 @@ +function openPopup() { + OneSignal.Slidedown.promptPush({force: true}); +} \ No newline at end of file