From d20015fa438e7d55eee7937afdcd06ca0201770a Mon Sep 17 00:00:00 2001 From: otsmr Date: Tue, 25 Mar 2025 00:11:07 +0100 Subject: [PATCH] ios version should work --- android/app/build.gradle | 2 +- .../connect => eu/twonly}/MainActivity.kt | 2 +- firebase.json | 2 +- ios/Runner.xcodeproj/project.pbxproj | 17 ++++++ ios/Runner/AppDelegate.swift | 9 +++ ios/Runner/GoogleService-Info.plist | 4 +- ios/Runner/Info.plist | 5 ++ ios/Runner/Runner.entitlements | 8 +++ lib/firebase_options.dart | 9 +-- lib/src/providers/api/media.dart | 1 - lib/src/services/fcm_service.dart | 12 ++-- lib/src/services/notification_service.dart | 59 ++++--------------- .../views/settings/settings_main_view.dart | 10 ++-- pubspec.yaml | 2 +- 14 files changed, 74 insertions(+), 68 deletions(-) rename android/app/src/main/kotlin/{com/example/connect => eu/twonly}/MainActivity.kt (79%) create mode 100644 ios/Runner/Runner.entitlements diff --git a/android/app/build.gradle b/android/app/build.gradle index e551980..802810e 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -15,7 +15,7 @@ if (keystorePropertiesFile.exists()) { } android { - namespace = "com.example.connect" + namespace = "eu.twonly" // compileSdk = flutter.compileSdkVersion compileSdk 35 //ndkVersion = flutter.ndkVersion diff --git a/android/app/src/main/kotlin/com/example/connect/MainActivity.kt b/android/app/src/main/kotlin/eu/twonly/MainActivity.kt similarity index 79% rename from android/app/src/main/kotlin/com/example/connect/MainActivity.kt rename to android/app/src/main/kotlin/eu/twonly/MainActivity.kt index 241c9e4..ce8739d 100644 --- a/android/app/src/main/kotlin/com/example/connect/MainActivity.kt +++ b/android/app/src/main/kotlin/eu/twonly/MainActivity.kt @@ -1,4 +1,4 @@ -package com.example.connect +package eu.twonly import io.flutter.embedding.android.FlutterFragmentActivity diff --git a/firebase.json b/firebase.json index 16d24a3..3f19ebf 100644 --- a/firebase.json +++ b/firebase.json @@ -1 +1 @@ -{"flutter":{"platforms":{"android":{"default":{"projectId":"twonly-ff605","appId":"1:650346093942:android:706cb87c3131dabe81ae57","fileOutput":"android/app/google-services.json"}},"ios":{"default":{"projectId":"twonly-ff605","appId":"1:650346093942:ios:e80075ff3de823c581ae57","uploadDebugSymbols":false,"fileOutput":"ios/Runner/GoogleService-Info.plist"}},"dart":{"lib/firebase_options.dart":{"projectId":"twonly-ff605","configurations":{"android":"1:650346093942:android:706cb87c3131dabe81ae57","ios":"1:650346093942:ios:e80075ff3de823c581ae57"}}}}}} \ No newline at end of file +{"flutter":{"platforms":{"android":{"default":{"projectId":"twonly-ff605","appId":"1:650346093942:android:040816fb819b1bfb81ae57","fileOutput":"android/app/google-services.json"}},"ios":{"default":{"projectId":"twonly-ff605","appId":"1:650346093942:ios:ee67080974eadb6681ae57","uploadDebugSymbols":false,"fileOutput":"ios/Runner/GoogleService-Info.plist"}},"dart":{"lib/firebase_options.dart":{"projectId":"twonly-ff605","configurations":{"android":"1:650346093942:android:040816fb819b1bfb81ae57","ios":"1:650346093942:ios:ee67080974eadb6681ae57"}}}}}} \ No newline at end of file diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 2dfafeb..4f701a7 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -66,6 +66,7 @@ 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; B3B27B7FBEEA31DB7793A0C2 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; + D2265DD42D920142000D99BB /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = ""; }; E96A5ACA32A7118204F050A5 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -133,6 +134,7 @@ 97C146F01CF9000F007C117D /* Runner */ = { isa = PBXGroup; children = ( + D2265DD42D920142000D99BB /* Runner.entitlements */, 97C146FA1CF9000F007C117D /* Main.storyboard */, 97C146FD1CF9000F007C117D /* Assets.xcassets */, 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, @@ -476,14 +478,19 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = CN332ZUGRP; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = twonly; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking"; + IPHONEOS_DEPLOYMENT_TARGET = 13; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); + MARKETING_VERSION = 0.0.5; PRODUCT_BUNDLE_IDENTIFIER = eu.twonly; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -664,14 +671,19 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = CN332ZUGRP; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = twonly; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking"; + IPHONEOS_DEPLOYMENT_TARGET = 13; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); + MARKETING_VERSION = 0.0.5; PRODUCT_BUNDLE_IDENTIFIER = eu.twonly; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -688,14 +700,19 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES; CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = CN332ZUGRP; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = twonly; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking"; + IPHONEOS_DEPLOYMENT_TARGET = 13; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); + MARKETING_VERSION = 0.0.5; PRODUCT_BUNDLE_IDENTIFIER = eu.twonly; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index 6266644..713d15e 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -7,6 +7,15 @@ import UIKit _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { + + if #available(iOS 10.0, *) { + UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate + } + + // if (@available(iOS 10.0, *)) { + // [UNUserNotificationCenter currentNotificationCenter].delegate = (id) self; + // } + GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } diff --git a/ios/Runner/GoogleService-Info.plist b/ios/Runner/GoogleService-Info.plist index cc43006..39c3bfd 100644 --- a/ios/Runner/GoogleService-Info.plist +++ b/ios/Runner/GoogleService-Info.plist @@ -9,7 +9,7 @@ PLIST_VERSION 1 BUNDLE_ID - com.example.connect + eu.twonly PROJECT_ID twonly-ff605 STORAGE_BUCKET @@ -25,6 +25,6 @@ IS_SIGNIN_ENABLED GOOGLE_APP_ID - 1:650346093942:ios:e80075ff3de823c581ae57 + 1:650346093942:ios:ee67080974eadb6681ae57 \ No newline at end of file diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 292b5ca..9ccfdb9 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -36,6 +36,11 @@ Store photos in the gallery. UIApplicationSupportsIndirectInputEvents + UIBackgroundModes + + fetch + remote-notification + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile diff --git a/ios/Runner/Runner.entitlements b/ios/Runner/Runner.entitlements new file mode 100644 index 0000000..903def2 --- /dev/null +++ b/ios/Runner/Runner.entitlements @@ -0,0 +1,8 @@ + + + + + aps-environment + development + + diff --git a/lib/firebase_options.dart b/lib/firebase_options.dart index 0c7d436..dce01b6 100644 --- a/lib/firebase_options.dart +++ b/lib/firebase_options.dart @@ -51,7 +51,7 @@ class DefaultFirebaseOptions { static const FirebaseOptions android = FirebaseOptions( apiKey: 'AIzaSyA4d5ORP11WpuVgmoYtWmOcMzZYWLPVtBk', - appId: '1:650346093942:android:706cb87c3131dabe81ae57', + appId: '1:650346093942:android:040816fb819b1bfb81ae57', messagingSenderId: '650346093942', projectId: 'twonly-ff605', storageBucket: 'twonly-ff605.firebasestorage.app', @@ -59,10 +59,11 @@ class DefaultFirebaseOptions { static const FirebaseOptions ios = FirebaseOptions( apiKey: 'AIzaSyDr7MEoz2XvrYxU0kYvZVVjej53q0gANnE', - appId: '1:650346093942:ios:e80075ff3de823c581ae57', + appId: '1:650346093942:ios:ee67080974eadb6681ae57', messagingSenderId: '650346093942', projectId: 'twonly-ff605', storageBucket: 'twonly-ff605.firebasestorage.app', - iosBundleId: 'com.example.connect', + iosBundleId: 'eu.twonly', ); -} + +} \ No newline at end of file diff --git a/lib/src/providers/api/media.dart b/lib/src/providers/api/media.dart index 69d0f91..6baa566 100644 --- a/lib/src/providers/api/media.dart +++ b/lib/src/providers/api/media.dart @@ -1,4 +1,3 @@ -import 'dart:collection'; import 'dart:convert'; import 'package:cryptography_plus/cryptography_plus.dart'; import 'package:drift/drift.dart'; diff --git a/lib/src/services/fcm_service.dart b/lib/src/services/fcm_service.dart index 4242982..5ce6bdf 100644 --- a/lib/src/services/fcm_service.dart +++ b/lib/src/services/fcm_service.dart @@ -6,7 +6,7 @@ import 'package:twonly/src/app.dart'; import 'package:twonly/src/database/twonly_database.dart'; import 'package:twonly/src/providers/api_provider.dart'; import 'package:twonly/src/utils/misc.dart'; - +import 'dart:io' show Platform; import '../../firebase_options.dart'; // see more here: https://firebase.google.com/docs/cloud-messaging/flutter/receive?hl=de @@ -52,10 +52,14 @@ Future initFCMService() async { await FirebaseMessaging.instance.requestPermission(provisional: true); // For apple platforms, ensure the APNS token is available before making any FCM plugin API calls - // final apnsToken = await FirebaseMessaging.instance.getAPNSToken(); - // if (apnsToken != null) { + if (Platform.isIOS) { + final apnsToken = await FirebaseMessaging.instance.getAPNSToken(); + if (apnsToken == null) { + return; + } + } + // APNS token is available, make FCM plugin API requests... - // } FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler); diff --git a/lib/src/services/notification_service.dart b/lib/src/services/notification_service.dart index 0603f9b..d1fe754 100644 --- a/lib/src/services/notification_service.dart +++ b/lib/src/services/notification_service.dart @@ -70,57 +70,16 @@ Future setupPushNotification() async { AndroidInitializationSettings("ic_launcher_foreground"); final List darwinNotificationCategories = - [ - DarwinNotificationCategory( - darwinNotificationCategoryText, - actions: [ - DarwinNotificationAction.text( - 'text_1', - 'Action 1', - buttonTitle: 'Send', - placeholder: 'Placeholder', - ), - ], - ), - DarwinNotificationCategory( - darwinNotificationCategoryPlain, - actions: [ - DarwinNotificationAction.plain('id_1', 'Action 1'), - DarwinNotificationAction.plain( - 'id_2', - 'Action 2 (destructive)', - options: { - DarwinNotificationActionOption.destructive, - }, - ), - DarwinNotificationAction.plain( - navigationActionId, - 'Action 3 (foreground)', - options: { - DarwinNotificationActionOption.foreground, - }, - ), - DarwinNotificationAction.plain( - 'id_4', - 'Action 4 (auth required)', - options: { - DarwinNotificationActionOption.authenticationRequired, - }, - ), - ], - options: { - DarwinNotificationCategoryOption.hiddenPreviewShowTitle, - }, - ) - ]; + []; /// Note: permissions aren't requested here just to demonstrate that can be /// done later final DarwinInitializationSettings initializationSettingsDarwin = DarwinInitializationSettings( - requestAlertPermission: false, - requestBadgePermission: false, - requestSoundPermission: false, + requestAlertPermission: true, + requestBadgePermission: true, + requestSoundPermission: true, + requestProvisionalPermission: false, notificationCategories: darwinNotificationCategories, ); @@ -220,8 +179,12 @@ Future localPushNotificationNewMessage( priority: Priority.max, ticker: 'You got a new message.', ); - const NotificationDetails notificationDetails = - NotificationDetails(android: androidNotificationDetails); + + const DarwinNotificationDetails darwinNotificationDetails = + DarwinNotificationDetails(); + const NotificationDetails notificationDetails = NotificationDetails( + android: androidNotificationDetails, iOS: darwinNotificationDetails); + await flutterLocalNotificationsPlugin.show( messageId, getContactDisplayName(user), diff --git a/lib/src/views/settings/settings_main_view.dart b/lib/src/views/settings/settings_main_view.dart index cabfa1c..17b8680 100644 --- a/lib/src/views/settings/settings_main_view.dart +++ b/lib/src/views/settings/settings_main_view.dart @@ -129,11 +129,11 @@ class _SettingsMainViewState extends State { })); }, ), - BetterListTile( - icon: FontAwesomeIcons.bell, - text: context.lang.settingsNotification, - onTap: () async {}, - ), + // BetterListTile( + // icon: FontAwesomeIcons.bell, + // text: context.lang.settingsNotification, + // onTap: () async {}, + // ), const Divider(), BetterListTile( icon: FontAwesomeIcons.circleQuestion, diff --git a/pubspec.yaml b/pubspec.yaml index 29d9ed5..88a92af 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ description: "Send pictures to friends in real time and be sure you are the only # Prevent accidental publishing to pub.dev. publish_to: 'none' -version: 0.0.4+4 +version: 0.0.5+5 environment: sdk: ^3.6.0