Skip to content

Commit b275e67

Browse files
sunitaprajapati89Sunita Prajapati
andauthored
feat: add iOS UIScene life cycle support (#220)
Register the core plugin as a scene delegate so deep links are received via scene(_:openURLContexts:) in apps that adopt the UIScene life cycle. The UIApplicationDelegate path is kept for apps that have not migrated. - Require Flutter >=3.38.0 (first release with the scene plugin API) - Bump segment_analytics to 1.2.0 - Migrate the example app to UIScene Fixes #192 Co-authored-by: Sunita Prajapati <sunita.kuamari@daffodilsw.com>
1 parent e8305f3 commit b275e67

14 files changed

Lines changed: 727 additions & 425 deletions

File tree

‎.github/actions/setup-flutter/action.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ inputs:
99
flutter-version:
1010
description: "Flutter SDK version to install from the stable channel"
1111
required: false
12-
default: "3.29.2"
12+
default: "3.38.0"
1313
sha256:
1414
description: "Expected SHA-256 of the Linux SDK archive. Empty skips verification."
1515
required: false

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ permissions:
1414
env:
1515
ARTIFACTORY_URL: ${{ vars.ARTIFACTORY_URL }}
1616
FLUTTER_SUPPRESS_ANALYTICS: "true"
17-
FLUTTER_VERSION: "3.29.2"
17+
FLUTTER_VERSION: "3.38.0"
1818

1919
jobs:
2020
test:
@@ -44,7 +44,7 @@ jobs:
4444
uses: ./.github/actions/setup-flutter
4545
with:
4646
flutter-version: ${{ env.FLUTTER_VERSION }}
47-
sha256: 6096f21370773093ec19240e133664c1c12eb8b5a85605a92d16ce462a18eac4
47+
sha256: c9cc746283f02dbad5da2785b4837b62f7956e3135fa9af87c7dde2d2bd6c5a6
4848

4949
- name: Authenticate with Artifactory
5050
if: ${{ !github.event.pull_request.head.repo.fork }}

‎.github/workflows/publish.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ permissions:
1717
env:
1818
ARTIFACTORY_URL: ${{ vars.ARTIFACTORY_URL }}
1919
FLUTTER_SUPPRESS_ANALYTICS: "true"
20-
FLUTTER_VERSION: "3.29.2"
20+
FLUTTER_VERSION: "3.38.0"
2121

2222
jobs:
2323
test:
@@ -36,7 +36,7 @@ jobs:
3636
uses: ./.github/actions/setup-flutter
3737
with:
3838
flutter-version: ${{ env.FLUTTER_VERSION }}
39-
sha256: 6096f21370773093ec19240e133664c1c12eb8b5a85605a92d16ce462a18eac4
39+
sha256: c9cc746283f02dbad5da2785b4837b62f7956e3135fa9af87c7dde2d2bd6c5a6
4040

4141
- name: Authenticate with Artifactory
4242
uses: ./.github/actions/artifactory-oidc
@@ -62,7 +62,7 @@ jobs:
6262
uses: ./.github/actions/setup-flutter
6363
with:
6464
flutter-version: ${{ env.FLUTTER_VERSION }}
65-
sha256: 6096f21370773093ec19240e133664c1c12eb8b5a85605a92d16ce462a18eac4
65+
sha256: c9cc746283f02dbad5da2785b4837b62f7956e3135fa9af87c7dde2d2bd6c5a6
6666

6767
- name: Publish to pub.dev (Trusted Publishing)
6868
run: dart pub publish --force

‎example/ios/Runner.xcodeproj/project.pbxproj‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
1111
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
1212
3B5C067C318D8DD07D23BA94 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 98E2D8A73DE7B28F12DCB802 /* Pods_Runner.framework */; };
13+
A1B2C3D41F00000100000001 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1B2C3D41F00000100000002 /* SceneDelegate.swift */; };
1314
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
1415
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
1516
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
@@ -36,6 +37,7 @@
3637
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3738
5D511AE6D5667D367382F8FB /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
3839
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
40+
A1B2C3D41F00000100000002 /* SceneDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
3941
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
4042
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
4143
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
@@ -115,6 +117,7 @@
115117
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
116118
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
117119
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
120+
A1B2C3D41F00000100000002 /* SceneDelegate.swift */,
118121
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
119122
);
120123
path = Runner;
@@ -280,6 +283,7 @@
280283
buildActionMask = 2147483647;
281284
files = (
282285
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
286+
A1B2C3D41F00000100000001 /* SceneDelegate.swift in Sources */,
283287
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
284288
);
285289
runOnlyForDeploymentPostprocessing = 0;
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import UIKit
22
import Flutter
33

4-
@UIApplicationMain
5-
@objc class AppDelegate: FlutterAppDelegate {
4+
@main
5+
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate {
66
override func application(
77
_ application: UIApplication,
88
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
99
) -> Bool {
10-
GeneratedPluginRegistrant.register(with: self)
1110
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
1211
}
12+
13+
func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) {
14+
GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)
15+
}
1316
}

‎example/ios/Runner/Info.plist‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,37 @@
4747
<true/>
4848
<key>UIApplicationSupportsIndirectInputEvents</key>
4949
<true/>
50+
<key>CFBundleURLTypes</key>
51+
<array>
52+
<dict>
53+
<key>CFBundleURLName</key>
54+
<string>segment.analytics.example</string>
55+
<key>CFBundleURLSchemes</key>
56+
<array>
57+
<string>segmentexample</string>
58+
</array>
59+
</dict>
60+
</array>
61+
<key>UIApplicationSceneManifest</key>
62+
<dict>
63+
<key>UIApplicationSupportsMultipleScenes</key>
64+
<false/>
65+
<key>UISceneConfigurations</key>
66+
<dict>
67+
<key>UIWindowSceneSessionRoleApplication</key>
68+
<array>
69+
<dict>
70+
<key>UISceneClassName</key>
71+
<string>UIWindowScene</string>
72+
<key>UISceneDelegateClassName</key>
73+
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
74+
<key>UISceneConfigurationName</key>
75+
<string>flutter</string>
76+
<key>UISceneStoryboardFile</key>
77+
<string>Main</string>
78+
</dict>
79+
</array>
80+
</dict>
81+
</dict>
5082
</dict>
5183
</plist>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Flutter
2+
import UIKit
3+
4+
class SceneDelegate: FlutterSceneDelegate {
5+
}

‎packages/core/CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.2.0
2+
3+
- Added iOS UIScene life cycle support (deep links are now received via `scene(_:openURLContexts:)`)
4+
- **Breaking:** requires Flutter 3.38 or newer. Apps on an older Flutter version should stay on `segment_analytics: 1.1.13`
5+
16
## 1.1.13
27

38
- Fixed Swift Package Manager support for iOS and macOS: the package now uses the layout Flutter 3.44+ expects (#213)

‎packages/core/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ Run:
5858

5959
`flutter pub add segment_analytics`
6060

61+
> **Flutter version compatibility:** `segment_analytics` 1.2.0 and newer require Flutter 3.38+ (iOS UIScene life cycle support). If you are on an older Flutter version, pin `segment_analytics: 1.1.13`.
62+
6163
```dart
6264
import 'package:segment_analytics/client.dart';
6365
```

‎packages/core/analysis_options.yaml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@ include: package:flutter_lints/flutter.yaml
22

33
# Additional information about this file can be found at
44
# https://dart.dev/guides/language/analysis-options
5+
6+
analyzer:
7+
exclude:
8+
# Generated by mockito; references Flutter-internal members that trigger
9+
# invalid_use_of_internal_member on newer Flutter versions.
10+
- test/mocks/mocks.mocks.dart

0 commit comments

Comments
 (0)