Skip to content

Commit

Permalink
bildirimler eklendi.
Browse files Browse the repository at this point in the history
  • Loading branch information
yolcura1@gmail.com authored and yolcura1@gmail.com committed Apr 26, 2020
1 parent f2083b9 commit 24b7c59
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"cloud_firestore","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\cloud_firestore-0.10.1\\\\","dependencies":["firebase_core"]},{"name":"firebase_analytics","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_analytics-2.1.1+3\\\\","dependencies":[]},{"name":"firebase_auth","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_auth-0.8.4+5\\\\","dependencies":["firebase_core"]},{"name":"firebase_core","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core-0.3.4\\\\","dependencies":[]},{"name":"google_sign_in","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\google_sign_in-4.0.1+3\\\\","dependencies":[]},{"name":"in_app_purchase","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\in_app_purchase-0.3.1+2\\\\","dependencies":[]},{"name":"webview_flutter","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\webview_flutter-0.3.19+9\\\\","dependencies":[]}],"android":[{"name":"cloud_firestore","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\cloud_firestore-0.10.1\\\\","dependencies":["firebase_core"]},{"name":"firebase_analytics","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_analytics-2.1.1+3\\\\","dependencies":[]},{"name":"firebase_auth","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_auth-0.8.4+5\\\\","dependencies":["firebase_core"]},{"name":"firebase_core","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core-0.3.4\\\\","dependencies":[]},{"name":"google_sign_in","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\google_sign_in-4.0.1+3\\\\","dependencies":[]},{"name":"in_app_purchase","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\in_app_purchase-0.3.1+2\\\\","dependencies":[]},{"name":"webview_flutter","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\webview_flutter-0.3.19+9\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"cloud_firestore","dependencies":["firebase_core"]},{"name":"firebase_analytics","dependencies":[]},{"name":"firebase_auth","dependencies":["firebase_core"]},{"name":"firebase_core","dependencies":[]},{"name":"google_sign_in","dependencies":[]},{"name":"in_app_purchase","dependencies":[]},{"name":"webview_flutter","dependencies":[]}],"date_created":"2020-04-23 23:24:59.768231","version":"1.15.17"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"cloud_firestore","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\cloud_firestore-0.12.11\\\\","dependencies":["firebase_core"]},{"name":"firebase_analytics","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_analytics-2.1.1+3\\\\","dependencies":[]},{"name":"firebase_auth","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_auth-0.11.1+12\\\\","dependencies":["firebase_core"]},{"name":"firebase_core","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core-0.4.4+3\\\\","dependencies":[]},{"name":"firebase_messaging","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_messaging-5.1.8\\\\","dependencies":[]},{"name":"google_sign_in","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\google_sign_in-4.0.1+3\\\\","dependencies":[]},{"name":"in_app_purchase","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\in_app_purchase-0.3.1+2\\\\","dependencies":[]},{"name":"webview_flutter","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\webview_flutter-0.3.19+9\\\\","dependencies":[]}],"android":[{"name":"cloud_firestore","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\cloud_firestore-0.12.11\\\\","dependencies":["firebase_core"]},{"name":"firebase_analytics","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_analytics-2.1.1+3\\\\","dependencies":[]},{"name":"firebase_auth","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_auth-0.11.1+12\\\\","dependencies":["firebase_core"]},{"name":"firebase_core","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core-0.4.4+3\\\\","dependencies":[]},{"name":"firebase_messaging","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_messaging-5.1.8\\\\","dependencies":[]},{"name":"google_sign_in","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\google_sign_in-4.0.1+3\\\\","dependencies":[]},{"name":"in_app_purchase","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\in_app_purchase-0.3.1+2\\\\","dependencies":[]},{"name":"webview_flutter","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\webview_flutter-0.3.19+9\\\\","dependencies":[]}],"macos":[{"name":"firebase_core","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core-0.4.4+3\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"firebase_core_web","path":"C:\\\\Users\\\\asus\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core_web-0.1.1+2\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"cloud_firestore","dependencies":["firebase_core"]},{"name":"firebase_analytics","dependencies":[]},{"name":"firebase_auth","dependencies":["firebase_core"]},{"name":"firebase_core","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","dependencies":[]},{"name":"firebase_messaging","dependencies":[]},{"name":"google_sign_in","dependencies":[]},{"name":"in_app_purchase","dependencies":[]},{"name":"webview_flutter","dependencies":[]}],"date_created":"2020-04-26 01:52:29.800497","version":"1.15.17"}
4 changes: 4 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.android.billingclient.api.ProxyBillingActivity"
Expand Down
113 changes: 113 additions & 0 deletions lib/services/notification.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import 'dart:async';
import 'dart:io';

import 'package:flutter/material.dart';

import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:cloud_firestore/cloud_firestore.dart';


class MessageHandler {
final Firestore _db = Firestore.instance;
final FirebaseMessaging _fcm = FirebaseMessaging();

StreamSubscription iosSubscription;


void initState(BuildContext context) {

if (Platform.isIOS) {
iosSubscription = _fcm.onIosSettingsRegistered.listen((data) {
print(data);
_saveDeviceToken();
});

_fcm.requestNotificationPermissions(IosNotificationSettings());
} else {
_saveDeviceToken();
}

_fcm.configure(
onMessage: (Map<String, dynamic> message) async {
print("onMessage: $message");
/*
final snackbar = SnackBar(
content: Text(message['notification']['title']),
action: SnackBarAction(
label: 'Go',
onPressed: () => null,
),
);
Scaffold.of(context).showSnackBar(snackbar);
*/


showDialog(
context: context,
builder: (context) => AlertDialog(
content: ListTile(
title: Text(message['notification']['title']),
subtitle: Text(message['notification']['body']),
),
actions: <Widget>[
FlatButton(
color: Colors.amber,
child: Text('Ok'),
onPressed: () => Navigator.of(context).pop(),
),
],
),
);
},
onLaunch: (Map<String, dynamic> message) async {
print("onLaunch: $message");
// TODO optional
},
onResume: (Map<String, dynamic> message) async {
print("onResume: $message");
// TODO optional
},
);

}


void disposeNotifications() {
if (iosSubscription != null) iosSubscription.cancel();

}


/// Get the token, save it to the database for current user
_saveDeviceToken() async {
// Get the current user
String uid = 'jeffd23';
// FirebaseUser user = await _auth.currentUser();

// Get the token for this device
String fcmToken = await _fcm.getToken();

// Save it to Firestore
if (fcmToken != null) {
var tokens = _db
.collection('users')
.document(uid)
.collection('tokens')
.document(fcmToken);

await tokens.setData({
'token': fcmToken,
'createdAt': FieldValue.serverTimestamp(), // optional
'platform': Platform.operatingSystem // optional
});
}
}

/// Subscribe the user to a topic
_subscribeToTopic() async {
// Subscribe the user to a topic
_fcm.subscribeToTopic('puppies');
}
}
4 changes: 3 additions & 1 deletion lib/shared/bottom_nav.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:define9/services/notification.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

final MessageHandler messageHandler = new MessageHandler();
class AppBottomNav extends StatelessWidget {
@override
Widget build(BuildContext context) {
messageHandler.initState(context);
return BottomNavigationBar(
items: [
BottomNavigationBarItem(
Expand Down
81 changes: 78 additions & 3 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ packages:
name: cloud_firestore
url: "https://pub.dartlang.org"
source: hosted
version: "0.10.1"
version: "0.12.11"
collection:
dependency: transitive
description:
Expand Down Expand Up @@ -71,6 +71,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2"
firebase:
dependency: transitive
description:
name: firebase
url: "https://pub.dartlang.org"
source: hosted
version: "7.3.0"
firebase_analytics:
dependency: "direct main"
description:
Expand All @@ -84,14 +91,35 @@ packages:
name: firebase_auth
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.4+5"
version: "0.11.1+12"
firebase_core:
dependency: "direct main"
description:
name: firebase_core
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.4"
version: "0.4.4+3"
firebase_core_platform_interface:
dependency: transitive
description:
name: firebase_core_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
firebase_core_web:
dependency: transitive
description:
name: firebase_core_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.1+2"
firebase_messaging:
dependency: "direct main"
description:
name: firebase_messaging
url: "https://pub.dartlang.org"
source: hosted
version: "5.1.8"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -109,6 +137,11 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
font_awesome_flutter:
dependency: "direct main"
description:
Expand All @@ -123,6 +156,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.1+3"
http:
dependency: transitive
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.0+4"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.4"
image:
dependency: transitive
description:
Expand All @@ -137,6 +184,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.1+2"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.1+1"
json_annotation:
dependency: transitive
description:
Expand Down Expand Up @@ -165,13 +219,34 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.0"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.1"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
provider:
dependency: "direct main"
description:
Expand Down
8 changes: 5 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ dependencies:
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2

firebase_core: ^0.3.4

firebase_analytics: ^2.1.1+3
firebase_core: ^0.4.0
firebase_auth: ^0.11.1+6
cloud_firestore: ^0.12.5
firebase_messaging: ^5.0.2

cloud_firestore: ^0.10.1

firebase_auth: ^0.8.4+5
google_sign_in: ^4.0.1+1

rxdart: ^0.21.0
Expand Down

0 comments on commit 24b7c59

Please sign in to comment.