Skip to content

Instantly share code, notes, and snippets.

@naumanahmed19
Created September 29, 2018 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naumanahmed19/805601aca49e5891e7c753a0ceeddb93 to your computer and use it in GitHub Desktop.
Save naumanahmed19/805601aca49e5891e7c753a0ceeddb93 to your computer and use it in GitHub Desktop.
A very simple example for firebase topics
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
void main() => runApp(MaterialApp(
home: MyApp(),
));
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
FirebaseMessaging _firebaseMessaging = new FirebaseMessaging();
@override
void initState() {
//for example your topic name is news
_firebaseMessaging.subscribeToTopic('news');
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('text'),
),
body: Container(
padding: EdgeInsets.all(32.0),
child: Center(
child: Column(
children: <Widget>[],
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment