Skip to content

Commit

Permalink
Remove firebase_messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
JAicewizard committed May 9, 2024
1 parent 6e96e63 commit e536be3
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 77 deletions.
44 changes: 0 additions & 44 deletions lib/blocs/auth_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@ import 'dart:async';
import 'dart:io';

import 'package:equatable/equatable.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:flutter_web_auth_2/flutter_web_auth_2.dart';
import 'package:oauth2/oauth2.dart';
import 'package:reaxit/api/api_repository.dart';
import 'package:reaxit/api/concrexit_api_repository.dart';
import 'package:reaxit/api/exceptions.dart';
import 'package:reaxit/config.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:shared_preferences/shared_preferences.dart';

final _redirectUrl = Uri.parse(
'nu.thalia://callback',
Expand Down Expand Up @@ -87,9 +83,6 @@ class FailureAuthState extends AuthState {
class AuthCubit extends Cubit<AuthState> {
AuthCubit() : super(LoadingAuthState());

/// A listener for refreshing push notification tokens.
StreamSubscription? _fmTokenSubscription;

/// Restore the authentication state from storage.
///
/// Looks for existing credentials and, if available,
Expand Down Expand Up @@ -154,12 +147,6 @@ class AuthCubit extends Cubit<AuthState> {
onLogOut: logOut,
);

try {
_setupPushNotifications(apiRepository);
} on FirebaseException {
// Ignore.
}

emit(LoggedInAuthState(apiRepository: apiRepository));
} else {
logOut();
Expand Down Expand Up @@ -254,8 +241,6 @@ class AuthCubit extends Cubit<AuthState> {
onLogOut: logOut,
);

await _setupPushNotifications(apiRepository);

emit(LoggedInAuthState(apiRepository: apiRepository));
} on PlatformException catch (exception) {
// Forward exceptions from the authentication flow.
Expand Down Expand Up @@ -310,33 +295,4 @@ class AuthCubit extends Cubit<AuthState> {
));
}
}

/// Set up push notifications.
///
/// Requests permission to display notifications, and registers
/// or updates a [Device] for push notifications on the backend.
///
/// Returns whether push notifications have been set up successfully or not.
Future<bool> _setupPushNotifications(ApiRepository api) async {
try {
// Request permissions for push notifications.
// We set up push notifications regardless of whether the user gives
// permission, so we don't need to keep track of the permission state,
// and the user can simply get push notifications working by enabling
// the permissions in the phone's settings.
FirebaseMessaging.instance.requestPermission(
alert: true,
announcement: true,
badge: true,
carPlay: false,
criticalAlert: false,
provisional: false,
sound: true,
);

return true;
} catch (_) {
return false;
}
}
}
32 changes: 0 additions & 32 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "61.0.0"
_flutterfire_internals:
dependency: transitive
description:
name: _flutterfire_internals
sha256: "1a52f1afae8ab7ac4741425114713bdbba802f1ce1e0648e167ffcc6e05e96cf"
url: "https://pub.dev"
source: hosted
version: "1.3.21"
add_2_calendar:
dependency: "direct main"
description:
Expand Down Expand Up @@ -353,30 +345,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.11.4"
firebase_messaging:
dependency: "direct main"
description:
name: firebase_messaging
sha256: "9c97b20c012542252a8853f11334efd833ddae83551fe37d27f87d885c655038"
url: "https://pub.dev"
source: hosted
version: "14.7.15"
firebase_messaging_platform_interface:
dependency: transitive
description:
name: firebase_messaging_platform_interface
sha256: d464b255e922c7915dc4b0ebc305ebad4e1f130519bee3d6e568ef2ea1613a4b
url: "https://pub.dev"
source: hosted
version: "4.5.23"
firebase_messaging_web:
dependency: transitive
description:
name: firebase_messaging_web
sha256: f3f71aeec719ec1fe2c99f75cd74d00d33f1c240cf1e402cc9d43883e84f935a
url: "https://pub.dev"
source: hosted
version: "3.6.4"
fixnum:
dependency: transitive
description:
Expand Down
1 change: 0 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ dependencies:

# Firebase for push notifications.
firebase_core: ^2.16.0
firebase_messaging: ^14.6.8

# Push notifications in app.
overlay_support: ^2.1.0
Expand Down

0 comments on commit e536be3

Please sign in to comment.