Skip to content

Commit

Permalink
Update notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedLSayed9 committed Jan 11, 2024
1 parent 1d81886 commit 2a7f106
Show file tree
Hide file tree
Showing 126 changed files with 1,775 additions and 1,717 deletions.
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
android:value="${ANDROID_GOOGLE_MAPS_API_KEY}" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="firebase_push_notification" />
android:value="high_importance_channel" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/notification_icon" />
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
classpath 'com.android.tools.build:gradle:7.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.14'
}
Expand Down
2 changes: 1 addition & 1 deletion functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ exports.senddevices = functions.firestore
title: "New Order!",
body: "New Delivery Order from \"" + userName + "\" has been added.",
},
data: {"tabName": "home"},
data: {"routeLocation": "/home"},
};

return fcm.sendToTopic(topic, message);
Expand Down
10 changes: 10 additions & 0 deletions ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import UIKit
import Flutter
import flutter_local_notifications
import GoogleMaps

@UIApplicationMain
Expand All @@ -18,6 +19,15 @@ import GoogleMaps

GMSServices.provideAPIKey(dartDefinesDictionary["IOS_GOOGLE_MAPS_API_KEY"] as? String ?? "");

// This is required to make any communication available in the action isolate.
FlutterLocalNotificationsPlugin.setPluginRegistrantCallback { (registry) in
GeneratedPluginRegistrant.register(with: registry)
}

if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate
}

GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
Expand Down
17 changes: 11 additions & 6 deletions lib/auth/domain/sign_in_with_email.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ mixin _$SignInWithEmail {
String get password => throw _privateConstructorUsedError;

@JsonKey(ignore: true)
$SignInWithEmailCopyWith<SignInWithEmail> get copyWith => throw _privateConstructorUsedError;
$SignInWithEmailCopyWith<SignInWithEmail> get copyWith =>
throw _privateConstructorUsedError;
}

/// @nodoc
abstract class $SignInWithEmailCopyWith<$Res> {
factory $SignInWithEmailCopyWith(SignInWithEmail value, $Res Function(SignInWithEmail) then) =
factory $SignInWithEmailCopyWith(
SignInWithEmail value, $Res Function(SignInWithEmail) then) =
_$SignInWithEmailCopyWithImpl<$Res, SignInWithEmail>;
@useResult
$Res call({String email, String password});
Expand Down Expand Up @@ -63,7 +65,8 @@ class _$SignInWithEmailCopyWithImpl<$Res, $Val extends SignInWithEmail>
}

/// @nodoc
abstract class _$$_SignInWithEmailCopyWith<$Res> implements $SignInWithEmailCopyWith<$Res> {
abstract class _$$_SignInWithEmailCopyWith<$Res>
implements $SignInWithEmailCopyWith<$Res> {
factory _$$_SignInWithEmailCopyWith(
_$_SignInWithEmail value, $Res Function(_$_SignInWithEmail) then) =
__$$_SignInWithEmailCopyWithImpl<$Res>;
Expand Down Expand Up @@ -122,7 +125,8 @@ class _$_SignInWithEmail implements _SignInWithEmail {
(other.runtimeType == runtimeType &&
other is _$_SignInWithEmail &&
(identical(other.email, email) || other.email == email) &&
(identical(other.password, password) || other.password == password));
(identical(other.password, password) ||
other.password == password));
}

@override
Expand All @@ -136,8 +140,9 @@ class _$_SignInWithEmail implements _SignInWithEmail {
}

abstract class _SignInWithEmail implements SignInWithEmail {
const factory _SignInWithEmail({required final String email, required final String password}) =
_$_SignInWithEmail;
const factory _SignInWithEmail(
{required final String email,
required final String password}) = _$_SignInWithEmail;

@override // Note: You should consider using separate value object (with its validator method)
// for these values if they're used in other entities.
Expand Down
18 changes: 12 additions & 6 deletions lib/auth/domain/user.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ mixin _$User {

/// @nodoc
abstract class $UserCopyWith<$Res> {
factory $UserCopyWith(User value, $Res Function(User) then) = _$UserCopyWithImpl<$Res, User>;
factory $UserCopyWith(User value, $Res Function(User) then) =
_$UserCopyWithImpl<$Res, User>;
@useResult
$Res call({String id, String email, String? name, String? phone, String? image});
$Res call(
{String id, String email, String? name, String? phone, String? image});
}

/// @nodoc
class _$UserCopyWithImpl<$Res, $Val extends User> implements $UserCopyWith<$Res> {
class _$UserCopyWithImpl<$Res, $Val extends User>
implements $UserCopyWith<$Res> {
_$UserCopyWithImpl(this._value, this._then);

// ignore: unused_field
Expand Down Expand Up @@ -82,13 +85,15 @@ abstract class _$$_UserCopyWith<$Res> implements $UserCopyWith<$Res> {
__$$_UserCopyWithImpl<$Res>;
@override
@useResult
$Res call({String id, String email, String? name, String? phone, String? image});
$Res call(
{String id, String email, String? name, String? phone, String? image});
}

/// @nodoc
class __$$_UserCopyWithImpl<$Res> extends _$UserCopyWithImpl<$Res, _$_User>
implements _$$_UserCopyWith<$Res> {
__$$_UserCopyWithImpl(_$_User _value, $Res Function(_$_User) _then) : super(_value, _then);
__$$_UserCopyWithImpl(_$_User _value, $Res Function(_$_User) _then)
: super(_value, _then);

@pragma('vm:prefer-inline')
@override
Expand Down Expand Up @@ -169,7 +174,8 @@ class _$_User extends _User {
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$_UserCopyWith<_$_User> get copyWith => __$$_UserCopyWithImpl<_$_User>(this, _$identity);
_$$_UserCopyWith<_$_User> get copyWith =>
__$$_UserCopyWithImpl<_$_User>(this, _$identity);
}

abstract class _User extends User {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 14 additions & 7 deletions lib/auth/infrastructure/dtos/user_dto.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ abstract class $UserDtoCopyWith<$Res> {
factory $UserDtoCopyWith(UserDto value, $Res Function(UserDto) then) =
_$UserDtoCopyWithImpl<$Res, UserDto>;
@useResult
$Res call({String id, String email, String? name, String? phone, String? image});
$Res call(
{String id, String email, String? name, String? phone, String? image});
}

/// @nodoc
class _$UserDtoCopyWithImpl<$Res, $Val extends UserDto> implements $UserDtoCopyWith<$Res> {
class _$UserDtoCopyWithImpl<$Res, $Val extends UserDto>
implements $UserDtoCopyWith<$Res> {
_$UserDtoCopyWithImpl(this._value, this._then);

// ignore: unused_field
Expand Down Expand Up @@ -84,15 +86,18 @@ class _$UserDtoCopyWithImpl<$Res, $Val extends UserDto> implements $UserDtoCopyW

/// @nodoc
abstract class _$$_UserDtoCopyWith<$Res> implements $UserDtoCopyWith<$Res> {
factory _$$_UserDtoCopyWith(_$_UserDto value, $Res Function(_$_UserDto) then) =
factory _$$_UserDtoCopyWith(
_$_UserDto value, $Res Function(_$_UserDto) then) =
__$$_UserDtoCopyWithImpl<$Res>;
@override
@useResult
$Res call({String id, String email, String? name, String? phone, String? image});
$Res call(
{String id, String email, String? name, String? phone, String? image});
}

/// @nodoc
class __$$_UserDtoCopyWithImpl<$Res> extends _$UserDtoCopyWithImpl<$Res, _$_UserDto>
class __$$_UserDtoCopyWithImpl<$Res>
extends _$UserDtoCopyWithImpl<$Res, _$_UserDto>
implements _$$_UserDtoCopyWith<$Res> {
__$$_UserDtoCopyWithImpl(_$_UserDto _value, $Res Function(_$_UserDto) _then)
: super(_value, _then);
Expand Down Expand Up @@ -142,7 +147,8 @@ class _$_UserDto extends _UserDto {
required this.image})
: super._();

factory _$_UserDto.fromJson(Map<String, dynamic> json) => _$$_UserDtoFromJson(json);
factory _$_UserDto.fromJson(Map<String, dynamic> json) =>
_$$_UserDtoFromJson(json);

@override
final String id;
Expand Down Expand Up @@ -213,5 +219,6 @@ abstract class _UserDto extends UserDto {
String? get image;
@override
@JsonKey(ignore: true)
_$$_UserDtoCopyWith<_$_UserDto> get copyWith => throw _privateConstructorUsedError;
_$$_UserDtoCopyWith<_$_UserDto> get copyWith =>
throw _privateConstructorUsedError;
}
3 changes: 2 additions & 1 deletion lib/auth/infrastructure/dtos/user_dto.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/auth/infrastructure/repos/auth_repo.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions lib/auth/presentation/providers/auth_state_provider.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/auth/presentation/providers/check_auth_provider.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/auth/presentation/providers/sign_in_provider.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '../../../core/infrastructure/services/fcm_service/fcm_provider.dart';
import '../../../core/infrastructure/notification/notification_service.dart';
import '../../../core/presentation/utils/fp_framework.dart';
import '../../../core/presentation/utils/riverpod_framework.dart';
import '../../domain/sign_in_with_email.dart';
Expand All @@ -21,7 +21,7 @@ class SignInState extends _$SignInState {
final authRepo = ref.read(authRepoProvider);
final userFromCredential = await authRepo.signInWithEmail(params);
final user = await authRepo.getUserData(userFromCredential.id);
await ref.read(fcmProvider).subscribeToTopic('general');
await ref.read(notificationServiceProvider).subscribeToTopic('general');

ref.read(authStateProvider.notifier).authenticateUser(user);

Expand Down
5 changes: 3 additions & 2 deletions lib/auth/presentation/providers/sign_in_provider.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions lib/auth/presentation/providers/sign_out_provider.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'dart:async';

import '../../../core/infrastructure/services/fcm_service/fcm_provider.dart';
import '../../../core/infrastructure/notification/notification_service.dart';
import '../../../core/presentation/extensions/future_extensions.dart';
import '../../../core/presentation/utils/fp_framework.dart';
import '../../../core/presentation/utils/riverpod_framework.dart';
Expand All @@ -18,7 +18,9 @@ class SignOutState extends _$SignOutState {
state = const AsyncLoading();
state = await AsyncValue.guard(() async {
unawaited(ref.read(authRepoProvider).signOut().suppressError());
unawaited(ref.read(fcmProvider).unsubscribeFromTopic('general').suppressError());
unawaited(
ref.read(notificationServiceProvider).unsubscribeFromTopic('general').suppressError(),
);

ref.read(authStateProvider.notifier).unAuthenticateUser();

Expand Down
5 changes: 3 additions & 2 deletions lib/auth/presentation/providers/sign_out_provider.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2a7f106

Please sign in to comment.