This file contains hidden or 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
import 'package:flutter/material.dart'; | |
import 'controller/form_controller.dart'; | |
import 'model/form.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( |
This file contains hidden or 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
import 'dart:convert' as convert; | |
import 'package:http/http.dart' as http; | |
import '../model/form.dart'; | |
/// FormController is a class which does work of saving FeedbackForm in Google Sheets using | |
/// HTTP GET request on Google App Script Web URL and parses response and sends result callback. | |
class FormController { | |
// Google App Script Web URL. | |
static const String URL = "https://script.google.com/macros/s/AKfycbyAaNh-1JK5pSrUnJ34Scp3889mTMuFI86DkDp42EkWiSOOycE/exec"; |
This file contains hidden or 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
/// FeedbackForm is a data class which stores data fields of Feedback. | |
class FeedbackForm { | |
String name; | |
String email; | |
String mobileNo; | |
String feedback; | |
FeedbackForm(this.name, this.email, this.mobileNo, this.feedback); | |
factory FeedbackForm.fromJson(dynamic json) { |
This file contains hidden or 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
function doPost(request){ | |
// Open Google Sheet using ID | |
var sheet = SpreadsheetApp.openById("1OOArrqjOqmD4GiJOWlluZ4woTMH_qaV6RKv4JXnT3Hk"); | |
var result = {"status": "SUCCESS"}; | |
try{ | |
// Get all Parameters | |
var name = request.parameter.name; | |
var email = request.parameter.email; | |
var mobileNo = request.parameter.mobileNo; | |
var feedback = request.parameter.feedback; |
This file contains hidden or 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
FirebaseMessaging.getInstance().subscribeToTopic("discount-offers") | |
.addOnCompleteListener { task -> | |
showToast("Subscribed! You will get all discount offers notifications") | |
if (!task.isSuccessful) { | |
showToast("Failed! Try again.") | |
} | |
} |
This file contains hidden or 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
class ScheduledWorker(appContext: Context, workerParams: WorkerParameters) : | |
Worker(appContext, workerParams) { | |
override fun doWork(): Result { | |
Log.d(TAG, "Work START") | |
// Get Notification Data | |
val title = inputData.getString(NOTIFICATION_TITLE) | |
val message = inputData.getString(NOTIFICATION_MESSAGE) |
This file contains hidden or 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
class NotificationBroadcastReceiver : BroadcastReceiver() { | |
override fun onReceive(context: Context?, intent: Intent?) { | |
intent?.let { | |
val title = it.getStringExtra(NOTIFICATION_TITLE) | |
val message = it.getStringExtra(NOTIFICATION_MESSAGE) | |
// Create Notification Data | |
val notificationData = Data.Builder() | |
.putString(NOTIFICATION_TITLE, title) |
This file contains hidden or 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
class MyFirebaseMessagingService : FirebaseMessagingService() { | |
override fun onMessageReceived(remoteMessage: RemoteMessage) { | |
// Check if message contains a data payload. | |
remoteMessage.data.isNotEmpty().let { | |
Log.d(TAG, "Message data payload: ${remoteMessage.data}") | |
// Get Message details | |
val title = remoteMessage.data["title"] | |
val message = remoteMessage.data["message"] |
This file contains hidden or 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
private fun scheduleAlarm( | |
scheduledTimeString: String?, | |
title: String?, | |
message: String? | |
) { | |
val alarmMgr = applicationContext.getSystemService(Context.ALARM_SERVICE) as AlarmManager | |
val alarmIntent = | |
Intent(applicationContext, NotificationBroadcastReceiver::class.java).let { intent -> | |
intent.putExtra(NOTIFICATION_TITLE, title) | |
intent.putExtra(NOTIFICATION_MESSAGE, message) |
This file contains hidden or 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
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
val navView = findViewById(R.id.nav_view) | |
navView.setItemStyle(MaterialNavigationView.ITEM_STYLE_ROUND_RIGHT) | |
navView.setItemStyle(MaterialNavigationView.ITEM_STYLE_ROUND_RECTANGLE) | |
} |