From 24e32f891eb214600c2c17cafd456097bce08986 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Fri, 27 Mar 2020 11:07:32 +0100 Subject: [PATCH] add ios notification example --- .../Notifications/NotificationService.swift | 6 +-- .../Notifications/Notifications.entitlements | 5 +-- example/ios/Runner.xcodeproj/project.pbxproj | 37 ++++++++++--------- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++ example/ios/Runner/Info.plist | 26 ++++++------- example/lib/main.dart | 4 +- 6 files changed, 46 insertions(+), 40 deletions(-) create mode 100644 example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/example/ios/Notifications/NotificationService.swift b/example/ios/Notifications/NotificationService.swift index a11a8574..bb724f71 100644 --- a/example/ios/Notifications/NotificationService.swift +++ b/example/ios/Notifications/NotificationService.swift @@ -19,16 +19,14 @@ class NotificationService: UNNotificationServiceExtension { defer { contentHandler(bestAttemptContent ?? request.content) } - print("DID RECEIVE NOTIFICATION") - // Modify the notification content here... - bestAttemptContent?.title = "\(bestAttemptContent?.title ?? "") [modified]" + // Modify the notification content here... + bestAttemptContent?.title = "[modified] \(bestAttemptContent?.title ?? "")" } override func serviceExtensionTimeWillExpire() { // Called just before the extension will be terminated by the system. // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used. if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent { - bestAttemptContent.title = "\(bestAttemptContent.title) [modified]" contentHandler(bestAttemptContent) } } diff --git a/example/ios/Notifications/Notifications.entitlements b/example/ios/Notifications/Notifications.entitlements index 903def2a..0c67376e 100644 --- a/example/ios/Notifications/Notifications.entitlements +++ b/example/ios/Notifications/Notifications.entitlements @@ -1,8 +1,5 @@ - - aps-environment - development - + diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index dd0ef5fc..477035e4 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -248,12 +248,12 @@ TargetAttributes = { 0BC14C4C242B5A7A0028DE94 = { CreatedOnToolsVersion = 11.4; - DevelopmentTeam = Q63BUTUB2B; + DevelopmentTeam = EHV7XZLAHA; ProvisioningStyle = Automatic; }; 97C146ED1CF9000F007C117D = { CreatedOnToolsVersion = 7.3.1; - DevelopmentTeam = Q63BUTUB2B; + DevelopmentTeam = EHV7XZLAHA; LastSwiftMigration = 1100; ProvisioningStyle = Automatic; }; @@ -425,14 +425,15 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_ENTITLEMENTS = Notifications/Notifications.entitlements; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = Q63BUTUB2B; + DEVELOPMENT_TEAM = EHV7XZLAHA; + ENABLE_BITCODE = NO; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = Notifications/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 13.4; + IPHONEOS_DEPLOYMENT_TARGET = 13.3; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = com.example.example.Notifications; + PRODUCT_BUNDLE_IDENTIFIER = io.stream.flutter.Notifications; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; @@ -452,13 +453,14 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_ENTITLEMENTS = Notifications/Notifications.entitlements; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = Q63BUTUB2B; + DEVELOPMENT_TEAM = EHV7XZLAHA; + ENABLE_BITCODE = NO; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = Notifications/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 13.4; + IPHONEOS_DEPLOYMENT_TARGET = 13.3; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = com.example.example.Notifications; + PRODUCT_BUNDLE_IDENTIFIER = io.stream.flutter.Notifications; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_VERSION = 5.0; @@ -476,13 +478,14 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_ENTITLEMENTS = Notifications/Notifications.entitlements; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = Q63BUTUB2B; + DEVELOPMENT_TEAM = EHV7XZLAHA; + ENABLE_BITCODE = NO; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = Notifications/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 13.4; + IPHONEOS_DEPLOYMENT_TARGET = 13.3; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = com.example.example.Notifications; + PRODUCT_BUNDLE_IDENTIFIER = io.stream.flutter.Notifications; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_VERSION = 5.0; @@ -552,7 +555,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = Q63BUTUB2B; + DEVELOPMENT_TEAM = EHV7XZLAHA; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -564,7 +567,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.example; + PRODUCT_BUNDLE_IDENTIFIER = io.stream.flutter; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -692,7 +695,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = Q63BUTUB2B; + DEVELOPMENT_TEAM = EHV7XZLAHA; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -704,7 +707,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.example; + PRODUCT_BUNDLE_IDENTIFIER = io.stream.flutter; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -725,7 +728,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = Q63BUTUB2B; + DEVELOPMENT_TEAM = EHV7XZLAHA; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -737,7 +740,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.example; + PRODUCT_BUNDLE_IDENTIFIER = io.stream.flutter; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index f6d694bd..ea713691 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -22,6 +22,19 @@ $(FLUTTER_BUILD_NUMBER) LSRequiresIPhoneOS + NSAppleMusicUsageDescription + Used to send message attachments + NSCameraUsageDescription + Used to send message attachments + NSMicrophoneUsageDescription + Used to send message attachments + NSPhotoLibraryUsageDescription + Used to send message attachments + UIBackgroundModes + + fetch + remote-notification + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile @@ -41,18 +54,5 @@ UIViewControllerBasedStatusBarAppearance - UIBackgroundModes - - fetch - remote-notification - - NSAppleMusicUsageDescription - Used to send message attachments - NSCameraUsageDescription - Used to send message attachments - NSMicrophoneUsageDescription - Used to send message attachments - NSPhotoLibraryUsageDescription - Used to send message attachments diff --git a/example/lib/main.dart b/example/lib/main.dart index 247ef027..4e5f92a2 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -33,8 +33,8 @@ void main() async { ); await client.setUser( - User(id: 'super-band-007'), - 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoic3VwZXItYmFuZC0wMDcifQ.DlbyHN6nK7jBTJDp6RJOuBJWwnYoy8Zq8208RPL4uLY', + User(id: 'user1'), + 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidXNlcjEifQ.NGZPyPMx7KSVisJmh4tJhOIv7ZjCaMQpOh4gTINvCaU', ); runApp(MyApp(client));