From b497fe0e87868c8f3ab4cf6e91d0e8c3519077ca Mon Sep 17 00:00:00 2001 From: Michael Bui <25263378+MaikuB@users.noreply.github.com> Date: Wed, 18 Dec 2019 22:16:19 +1100 Subject: [PATCH] Enable better compatibility with other notification plugins, readme and Proguard/R8 updates (#398) * remove comments from license file * update gitignore and podfile.lock * remove registering plugin as UNUserNotificationCenterDelegate * bump Android dependencies * remove unused ios code * apply suggestions from Android Studio to simplify if statements * bump Flutter dependencies * bump version in pubspec, update gitignore and remove meta dependency * update proguard rules, changelog * add info on removing dependency on meta * update changelog, migrate new platforms manifest, remove podfile files from example * change image used for cirrus ios task * remove deprecated author field from pubspec * update changelog to mention bumping target and compile SDK versions to 29 --- .cirrus.yml | 2 +- CHANGELOG.md | 9 +++ LICENSE | 54 ++++++++-------- README.md | 31 ++++++--- android/build.gradle | 8 +-- .../FlutterLocalNotificationsPlugin.java | 14 +--- example/.gitignore | 39 +++++++++-- example/android/app/build.gradle | 25 ++++++-- example/android/app/proguard-rules.pro | 35 ++++++++++ example/android/app/src/main/res/raw/keep.xml | 3 + example/android/build.gradle | 2 +- example/android/gradle.properties | 3 +- .../gradle/wrapper/gradle-wrapper.properties | 4 +- example/ios/.gitignore | 64 ++++++++----------- example/ios/Podfile | 63 ------------------ example/ios/Podfile.lock | 34 ---------- example/ios/Runner/AppDelegate.m | 3 + example/pubspec.yaml | 11 ++-- ios/Classes/FlutterLocalNotificationsPlugin.h | 2 +- ios/Classes/FlutterLocalNotificationsPlugin.m | 7 -- lib/src/flutter_local_notifications.dart | 2 +- pubspec.yaml | 20 +++--- 22 files changed, 210 insertions(+), 225 deletions(-) create mode 100644 example/android/app/proguard-rules.pro create mode 100644 example/android/app/src/main/res/raw/keep.xml delete mode 100644 example/ios/Podfile delete mode 100644 example/ios/Podfile.lock diff --git a/.cirrus.yml b/.cirrus.yml index c0ca71e23..b8596a1a1 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -9,7 +9,7 @@ build_example_android_task: build_example_ios_task: osx_instance: - image: mojave-xcode-10.2-flutter + image: mojave-flutter pub_cache: folder: ~/.pub-cache update_pods_script: pod repo update # to fetch all the latest versions diff --git a/CHANGELOG.md b/CHANGELOG.md index 76c8a9a84..05d540321 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,13 @@ +# [0.9.0] +* [Android] Add ability to customise visibility of a notification on the lockscreen. Thanks to PR by [gianlucaparadise](https://github.com/gianlucaparadise) +* [Android] Bumped compile and target SDK to 29 +* **BREAKING CHANGE** [iOS] Plugin no longer registers as a `UNUserNotificationCenterDelegate`. This is to enable compatibility with other plugins that display notifications. Developers must now do this themselves. Refer to the updated iOS integration section for more info on this +* Updated info about configuring Proguard configuration rules and included a file that could be used for reference in the example app +* Removed dependency on the `meta` package +* **BREAKING CHANGE** Now requires Flutter SDK 1.10.0 or greater +* Migrate the plugin to the pubspec platforms manifest + # [0.8.4+3] * Update example to fix issue [372](https://github.com/MaikuB/flutter_local_notifications/issues/372) around app not firing `onSelectNotification` having switched to using streams and initialising the app in the `main` function. diff --git a/LICENSE b/LICENSE index b76af5bbc..d666ea446 100644 --- a/LICENSE +++ b/LICENSE @@ -1,27 +1,27 @@ -// Copyright 2018 Michael Bui. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +Copyright 2018 Michael Bui. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of the copyright holder nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/README.md b/README.md index ff4c47a13..ed7207ca1 100644 --- a/README.md +++ b/README.md @@ -316,16 +316,36 @@ When specifying the large icon bitmap or big picture bitmap (associated with the Note that with Android 8.0+, sounds and vibrations are associated with notification channels and can only be configured when they are first created. Showing/scheduling a notification will create a channel with the specified id if it doesn't exist already. If another notification specifies the same channel id but tries to specify another sound or vibration pattern then nothing occurs. -When doing a release build of your app, you'll likely need to customise your ProGuard configuration file as per this [link](https://developer.android.com/studio/build/shrink-code#keep-code) and add the following line +When doing a release build of your app, you'll likely need to customise your ProGuard configuration file as per this [link](https://developer.android.com/studio/build/shrink-code#keep-code) and add the following line. If you have resource shrinking enabled, ensure that you have customised the resources that should be kept so that things like your notification images aren't discarded by following the instructions [here](https://developer.android.com/studio/build/shrink-code#keep-resources). ``` -keep class com.dexterous.** { *; } ``` +The plugin also makes use of GSON and the Proguard rules can be found [here](https://github.com/google/gson/blob/master/examples/android-proguard-example/proguard.cfg). The example app has a consolidate Proguard rules (`proguard-rules.pro`) file that combines these together for reference. + **IMPORTANT**: Starting from version 0.5.0, this library no longer uses the deprecated Android support libraries and has migrated to AndroidX. Developers may require migrating their apps to support this following [this guide](https://developer.android.com/jetpack/androidx/migrate) ## iOS Integration +Add the following lines to the `didFinishLaunchingWithOptions` method in the AppDelegate.m/AppDelegate.swift file of your iOS project + +Objective-C + +Objective-C: +```objc +if (@available(iOS 10.0, *)) { + [UNUserNotificationCenter currentNotificationCenter].delegate = (id) self; +} +``` + +Swift: +```swift +if #available(iOS 10.0, *) { + UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate +} +``` + By design, iOS applications do not display notifications when they're in the foreground. For iOS 10+, use the presentation options to control the behaviour for when a notification is triggered while the app is in the foreground. For older versions of iOS, you need to handle the callback as part of specifying the method that should be fired to the `onDidReceiveLocalNotification` argument when creating an instance `IOSInitializationSettings` object that is passed to the function for initializing the plugin. A snippet below from the sample app shows how this can be done ```dart @@ -383,14 +403,7 @@ When using custom notification sound, developers should be aware that iOS enforc https://developer.apple.com/documentation/usernotifications/unnotificationsound?language=objc -**NOTE**: this plugin registers itself as the delegate to handle incoming notifications and actions. This may cause problems if you're using other plugins for push notifications (e.g. `firebase_messaging`) as they will most likely do the same and it's only possible to register a single delegate. iOS handles showing push notifications out of the box so if you're only using this plugin to display the notification payload on Android then it's suggested that you fork the plugin code and remove the following part in the iOS code - -```objc -UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; -center.delegate = instance; -``` - -Unfortunately, this platform limitation does mean that it's not possible to use this plugin together other plugins for push notifications on iOS. If you are in this situation, then my only advice is that you'll need to need to look at writing customised platform-specific code for your application that may involve taking bits and pieces of code from the plugins you need. +**IMPORTANT**: There is an issue that prevents this plugin working properly with the `firebase_messaging` plugin at this point in time. This is being tracked [here](https://github.com/FirebaseExtended/flutterfire/issues/1455). Please upvote if this issue is important to you for the Flutter team to prioritise ## Testing diff --git a/android/build.gradle b/android/build.gradle index 6b2705b26..71b51dc64 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -8,7 +8,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.4.0' + classpath 'com.android.tools.build:gradle:3.5.0' } } @@ -22,7 +22,7 @@ rootProject.allprojects { apply plugin: 'com.android.library' android { - compileSdkVersion 28 + compileSdkVersion 29 defaultConfig { minSdkVersion 16 @@ -34,6 +34,6 @@ android { } dependencies { - implementation "androidx.core:core:1.0.1" - implementation "com.google.code.gson:gson:2.8.2" + implementation "androidx.core:core:1.1.0" + implementation "com.google.code.gson:gson:2.8.5" } diff --git a/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java b/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java index 6eec8ec67..6d502be43 100644 --- a/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java +++ b/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java @@ -788,25 +788,17 @@ private boolean hasInvalidBigPictureResources(Result result, NotificationDetails BigPictureStyleInformation bigPictureStyleInformation = (BigPictureStyleInformation) notificationDetails.styleInformation; if (hasInvalidLargeIcon(result, bigPictureStyleInformation.largeIcon, bigPictureStyleInformation.largeIconBitmapSource)) return true; - if (bigPictureStyleInformation.bigPictureBitmapSource == BitmapSource.Drawable && !isValidDrawableResource(registrar.context(), bigPictureStyleInformation.bigPicture, result, INVALID_BIG_PICTURE_ERROR_CODE)) { - return true; - } + return bigPictureStyleInformation.bigPictureBitmapSource == BitmapSource.Drawable && !isValidDrawableResource(registrar.context(), bigPictureStyleInformation.bigPicture, result, INVALID_BIG_PICTURE_ERROR_CODE); } return false; } private boolean hasInvalidLargeIcon(Result result, String largeIcon, BitmapSource largeIconBitmapSource) { - if (!StringUtils.isNullOrEmpty(largeIcon) && largeIconBitmapSource == BitmapSource.Drawable && !isValidDrawableResource(registrar.context(), largeIcon, result, INVALID_LARGE_ICON_ERROR_CODE)) { - return true; - } - return false; + return !StringUtils.isNullOrEmpty(largeIcon) && largeIconBitmapSource == BitmapSource.Drawable && !isValidDrawableResource(registrar.context(), largeIcon, result, INVALID_LARGE_ICON_ERROR_CODE); } private boolean hasInvalidIcon(Result result, String icon) { - if (!StringUtils.isNullOrEmpty(icon) && !isValidDrawableResource(registrar.context(), icon, result, INVALID_ICON_ERROR_CODE)) { - return true; - } - return false; + return !StringUtils.isNullOrEmpty(icon) && !isValidDrawableResource(registrar.context(), icon, result, INVALID_ICON_ERROR_CODE); } private void cancelNotification(Integer id) { diff --git a/example/.gitignore b/example/.gitignore index a03e2bf32..d16b8eba3 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -1,10 +1,37 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp .DS_Store .atom/ -.idea -.vscode/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies .packages +.pub-cache/ .pub/ -build/ -ios/.generated/ -packages -.flutter-plugins +/build/ + +# Web related +lib/generated_plugin_registrant.dart + +# Exceptions to above rules. +!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages \ No newline at end of file diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 238c936ec..d21d43603 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -15,7 +15,7 @@ apply plugin: 'com.android.application' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 28 + compileSdkVersion 29 lintOptions { disable 'InvalidPackage' @@ -25,7 +25,7 @@ android { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.dexterous.flutterlocalnotificationsexample" minSdkVersion 16 - targetSdkVersion 28 + targetSdkVersion 29 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" @@ -36,6 +36,21 @@ android { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. signingConfig signingConfigs.debug + + // Enables code shrinking, obfuscation, and optimization for only + // your project's release build type. + minifyEnabled true + + // Enables resource shrinking, which is performed by the + // Android Gradle plugin. + shrinkResources true + + // Includes the default ProGuard rules files that are packaged with + // the Android Gradle plugin. To learn more, go to the section about + // R8 configuration files. + proguardFiles getDefaultProguardFile( + 'proguard-android-optimize.txt'), + 'proguard-rules.pro' } } } @@ -46,7 +61,7 @@ flutter { dependencies { testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test:runner:1.1.1' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' - implementation "androidx.core:core:1.0.1" + androidTestImplementation 'androidx.test:runner:1.2.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + implementation "androidx.core:core:1.1.0" } diff --git a/example/android/app/proguard-rules.pro b/example/android/app/proguard-rules.pro new file mode 100644 index 000000000..26c2d5a10 --- /dev/null +++ b/example/android/app/proguard-rules.pro @@ -0,0 +1,35 @@ +## Flutter wrapper +-keep class io.flutter.app.** { *; } +-keep class io.flutter.plugin.** { *; } +-keep class io.flutter.util.** { *; } +-keep class io.flutter.view.** { *; } +-keep class io.flutter.** { *; } +-keep class io.flutter.plugins.** { *; } +-dontwarn io.flutter.embedding.** + +## Gson rules +# Gson uses generic type information stored in a class file when working with fields. Proguard +# removes such information by default, so configure it to keep all of it. +-keepattributes Signature + +# For using GSON @Expose annotation +-keepattributes *Annotation* + +# Gson specific classes +-dontwarn sun.misc.** +#-keep class com.google.gson.stream.** { *; } + +# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory, +# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter) +-keep class * implements com.google.gson.TypeAdapter +-keep class * implements com.google.gson.TypeAdapterFactory +-keep class * implements com.google.gson.JsonSerializer +-keep class * implements com.google.gson.JsonDeserializer + +# Prevent R8 from leaving Data object members always null +-keepclassmembers,allowobfuscation class * { + @com.google.gson.annotations.SerializedName ; +} + +## flutter_local_notification plugin rules +-keep class com.dexterous.** { *; } \ No newline at end of file diff --git a/example/android/app/src/main/res/raw/keep.xml b/example/android/app/src/main/res/raw/keep.xml new file mode 100644 index 000000000..944a7ace3 --- /dev/null +++ b/example/android/app/src/main/res/raw/keep.xml @@ -0,0 +1,3 @@ + + \ No newline at end of file diff --git a/example/android/build.gradle b/example/android/build.gradle index 10a56be98..f6838e08f 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -5,7 +5,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.4.0' + classpath 'com.android.tools.build:gradle:3.5.0' } } diff --git a/example/android/gradle.properties b/example/android/gradle.properties index 4d3226abc..a6738207f 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -1,3 +1,4 @@ org.gradle.jvmargs=-Xmx1536M android.useAndroidX=true -android.enableJetifier=true \ No newline at end of file +android.enableJetifier=true +android.enableR8=true diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index e1025d984..9ea9a4b8c 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sat Apr 20 22:14:21 AEST 2019 +#Tue Sep 24 10:09:39 AEST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/example/ios/.gitignore b/example/ios/.gitignore index 4ba4752bb..c171b3693 100644 --- a/example/ios/.gitignore +++ b/example/ios/.gitignore @@ -1,43 +1,35 @@ -.idea/ -.vagrant/ -.sconsign.dblite -.svn/ - -.DS_Store -*.swp -profile - -DerivedData/ -build/ -GeneratedPluginRegistrant.h -GeneratedPluginRegistrant.m - -*.pbxuser *.mode1v3 *.mode2v3 +*.moved-aside +*.pbxuser *.perspectivev3 - -!default.pbxuser +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. !default.mode1v3 !default.mode2v3 +!default.pbxuser !default.perspectivev3 -xcuserdata - -*.moved-aside - -*.pyc -*sync/ -Icon? -.tags* - -/Flutter/app.flx -/Flutter/app.zip -/Flutter/flutter_assets/ -/Flutter/flutter_export_environment.sh -/Flutter/App.framework -/Flutter/Flutter.framework -/Flutter/Generated.xcconfig -/ServiceDefinitions.json - -Pods/ +Podfile +Podfile.lock \ No newline at end of file diff --git a/example/ios/Podfile b/example/ios/Podfile deleted file mode 100644 index 4b4453246..000000000 --- a/example/ios/Podfile +++ /dev/null @@ -1,63 +0,0 @@ -# Uncomment this line to define a global platform for your project -# platform :ios, '9.0' - -# CocoaPods analytics sends network stats synchronously affecting flutter build latency. -ENV['COCOAPODS_DISABLE_STATS'] = 'true' - -def parse_KV_file(file, separator='=') - file_abs_path = File.expand_path(file) - if !File.exists? file_abs_path - return []; - end - pods_ary = [] - skip_line_start_symbols = ["#", "/"] - File.foreach(file_abs_path) { |line| - next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } - plugin = line.split(pattern=separator) - if plugin.length == 2 - podname = plugin[0].strip() - path = plugin[1].strip() - podpath = File.expand_path("#{path}", file_abs_path) - pods_ary.push({:name => podname, :path => podpath}); - else - puts "Invalid plugin specification: #{line}" - end - } - return pods_ary -end - -target 'Runner' do - # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock - # referring to absolute paths on developers' machines. - system('rm -rf Pods/.symlinks') - system('mkdir -p Pods/.symlinks/plugins') - - # Flutter Pods - generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig') - if generated_xcode_build_settings.empty? - puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first." - end - generated_xcode_build_settings.map { |p| - if p[:name] == 'FLUTTER_FRAMEWORK_DIR' - symlink = File.join('Pods', '.symlinks', 'flutter') - File.symlink(File.dirname(p[:path]), symlink) - pod 'Flutter', :path => File.join(symlink, File.basename(p[:path])) - end - } - - # Plugin Pods - plugin_pods = parse_KV_file('../.flutter-plugins') - plugin_pods.map { |p| - symlink = File.join('Pods', '.symlinks', 'plugins', p[:name]) - File.symlink(p[:path], symlink) - pod p[:name], :path => File.join(symlink, 'ios') - } -end - -post_install do |installer| - installer.pods_project.targets.each do |target| - target.build_configurations.each do |config| - config.build_settings['ENABLE_BITCODE'] = 'NO' - end - end -end \ No newline at end of file diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock deleted file mode 100644 index 5a83acaca..000000000 --- a/example/ios/Podfile.lock +++ /dev/null @@ -1,34 +0,0 @@ -PODS: - - Flutter (1.0.0) - - flutter_local_notifications (0.0.1): - - Flutter - - path_provider (0.0.1): - - Flutter - - shared_preferences (0.0.1): - - Flutter - -DEPENDENCIES: - - Flutter (from `Pods/.symlinks/flutter/ios`) - - flutter_local_notifications (from `Pods/.symlinks/plugins/flutter_local_notifications/ios`) - - path_provider (from `Pods/.symlinks/plugins/path_provider/ios`) - - shared_preferences (from `Pods/.symlinks/plugins/shared_preferences/ios`) - -EXTERNAL SOURCES: - Flutter: - :path: Pods/.symlinks/flutter/ios - flutter_local_notifications: - :path: Pods/.symlinks/plugins/flutter_local_notifications/ios - path_provider: - :path: Pods/.symlinks/plugins/path_provider/ios - shared_preferences: - :path: Pods/.symlinks/plugins/shared_preferences/ios - -SPEC CHECKSUMS: - Flutter: 0e3d915762c693b495b44d77113d4970485de6ec - flutter_local_notifications: 9e4738ce2471c5af910d961a6b7eadcf57c50186 - path_provider: f96fff6166a8867510d2c25fdcc346327cc4b259 - shared_preferences: 1feebfa37bb57264736e16865e7ffae7fc99b523 - -PODFILE CHECKSUM: a58e19c59fdbf6af9d1c82e73a979aef236a37de - -COCOAPODS: 1.8.4 diff --git a/example/ios/Runner/AppDelegate.m b/example/ios/Runner/AppDelegate.m index 027a6c482..d02ee50df 100644 --- a/example/ios/Runner/AppDelegate.m +++ b/example/ios/Runner/AppDelegate.m @@ -11,6 +11,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( [[UIApplication sharedApplication] cancelAllLocalNotifications]; [[NSUserDefaults standardUserDefaults]setBool:YES forKey:@"Notification"]; } + if(@available(iOS 10.0, *)) { + [UNUserNotificationCenter currentNotificationCenter].delegate = (id) self; + } // Override point for customization after application launch. return [super application:application didFinishLaunchingWithOptions:launchOptions]; } diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 242dd6a7d..2960dee36 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -7,12 +7,11 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^0.1.0 - http: ^0.12.0 - path_provider: ^0.4.1 - shared_preferences: ^0.4.3 - rxdart: ^0.22.6 - + cupertino_icons: ^0.1.3 + http: ^0.12.0+2 + path_provider: ^1.5.1 + shared_preferences: ^0.5.6 + rxdart: ^0.23.1 dev_dependencies: flutter_test: diff --git a/ios/Classes/FlutterLocalNotificationsPlugin.h b/ios/Classes/FlutterLocalNotificationsPlugin.h index 11ab307c6..10689d416 100644 --- a/ios/Classes/FlutterLocalNotificationsPlugin.h +++ b/ios/Classes/FlutterLocalNotificationsPlugin.h @@ -1,5 +1,5 @@ #import #import -@interface FlutterLocalNotificationsPlugin : NSObject +@interface FlutterLocalNotificationsPlugin : NSObject @end diff --git a/ios/Classes/FlutterLocalNotificationsPlugin.m b/ios/Classes/FlutterLocalNotificationsPlugin.m index 3c44caf6e..0e358fa7e 100644 --- a/ios/Classes/FlutterLocalNotificationsPlugin.m +++ b/ios/Classes/FlutterLocalNotificationsPlugin.m @@ -18,7 +18,6 @@ @implementation FlutterLocalNotificationsPlugin{ } NSString *const INITIALIZE_METHOD = @"initialize"; -NSString *const INITIALIZED_HEADLESS_SERVICE_METHOD = @"initializedHeadlessService"; NSString *const SHOW_METHOD = @"show"; NSString *const SCHEDULE_METHOD = @"schedule"; NSString *const PERIODICALLY_SHOW_METHOD = @"periodicallyShow"; @@ -78,10 +77,6 @@ + (void)registerWithRegistrar:(NSObject*)registrar { FlutterLocalNotificationsPlugin* instance = [[FlutterLocalNotificationsPlugin alloc] initWithChannel:channel registrar:registrar]; [registrar addApplicationDelegate:instance]; [registrar addMethodCallDelegate:instance channel:channel]; - if(@available(iOS 10.0, *)) { - UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; - center.delegate = instance; - } } - (instancetype)initWithChannel:(FlutterMethodChannel *)channel registrar:(NSObject *)registrar { @@ -311,8 +306,6 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { } NSDictionary *notificationAppLaunchDetails = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:launchingAppFromNotification], NOTIFICATION_LAUNCHED_APP, payload, PAYLOAD, nil]; result(notificationAppLaunchDetails); - } else if([INITIALIZED_HEADLESS_SERVICE_METHOD isEqualToString:call.method]) { - result(nil); } else if([PENDING_NOTIFICATIONS_REQUESTS_METHOD isEqualToString:call.method]) { [self pendingNotificationRequests:result]; } diff --git a/lib/src/flutter_local_notifications.dart b/lib/src/flutter_local_notifications.dart index 59194017d..d219ab756 100644 --- a/lib/src/flutter_local_notifications.dart +++ b/lib/src/flutter_local_notifications.dart @@ -1,7 +1,7 @@ import 'dart:io'; import 'dart:async'; +import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; -import 'package:meta/meta.dart'; import 'package:platform/platform.dart'; import 'initialization_settings.dart'; import 'notification_app_launch_details.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index 70087d82c..317282b29 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,28 +1,28 @@ name: flutter_local_notifications description: A cross platform plugin for displaying and scheduling local notifications for Flutter applications with the ability to customise for each platform. -version: 0.8.4+3 -author: Michael Bui +version: 0.9.0 homepage: https://github.com/MaikuB/flutter_local_notifications dependencies: flutter: sdk: flutter - meta: ^1.1.6 - platform: ^2.2.0 + platform: ^2.2.1 dev_dependencies: flutter_test: sdk: flutter - mockito: ^4.1.0 + mockito: ^4.1.1 - -# The following section is specific to Flutter. flutter: plugin: - androidPackage: com.dexterous.flutterlocalnotifications - pluginClass: FlutterLocalNotificationsPlugin + platforms: + android: + package: com.dexterous.flutterlocalnotifications + pluginClass: FlutterLocalNotificationsPlugin + ios: + pluginClass: FlutterLocalNotificationsPlugin environment: sdk: ">=2.0.0-dev.28.0 <3.0.0" - flutter: ">=1.5.0 <2.0.0" \ No newline at end of file + flutter: ">=1.10.0 <2.0.0" \ No newline at end of file