Skip to content

Commit 466b1e9

Browse files
chore: update template
1 parent 31827e9 commit 466b1e9

6 files changed

Lines changed: 36 additions & 142 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ local.properties
3737
#
3838
**/Pods/
3939
ios/MendixAppDelegate.m
40+
ios/MendixAppDelegate.swift
4041

4142
# node.js
4243
#

capabilities-setup-config.json

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"ios": {
44
"AppDelegate": {
55
"imports": [
6-
"#import \"React/RCTLinkingManager.h\""
6+
"import React"
77
],
88
"boolean_openURLWithOptions": [
9-
"return [RCTLinkingManager application:application openURL:url options:options];"
9+
"return RCTLinkingManager.application(application, open: url, options: options)"
1010
]
1111
}
1212
}
@@ -36,24 +36,6 @@
3636
"externalDependencies": [
3737
"me.leolin:ShortcutBadger:1.1.22@aar"
3838
]
39-
},
40-
"ios": {
41-
"AppDelegate": {
42-
"imports": [
43-
"#import <RNCPushNotificationIOS.h>"
44-
],
45-
"didFinishLaunchingWithOptions": [
46-
"UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];",
47-
"center.delegate = MendixAppDelegate.delegate;"
48-
],
49-
"willPresentNotification": [
50-
"completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge);"
51-
],
52-
"didReceiveNotificationResponse": [
53-
"[RNCPushNotificationIOS didReceiveNotificationResponse:response];",
54-
"completionHandler();"
55-
]
56-
}
5739
}
5840
},
5941
"firebaseAndroid": {
@@ -72,10 +54,10 @@
7254
"ios": {
7355
"AppDelegate": {
7456
"imports": [
75-
"#import <Firebase.h>"
57+
"import FirebaseCore"
7658
],
7759
"didFinishLaunchingWithOptions": [
78-
"[FIRApp configure];"
60+
"FirebaseApp.configure()"
7961
]
8062
}
8163
}
@@ -85,10 +67,10 @@
8567
"ios": {
8668
"AppDelegate": {
8769
"imports": [
88-
"#import <GoogleMaps/GoogleMaps.h>"
70+
"import GoogleMaps"
8971
],
9072
"didFinishLaunchingWithOptions": [
91-
"[GMSServices provideAPIKey:[[NSBundle mainBundle] objectForInfoDictionaryKey:@\"GoogleMapsApiKey\"] ?: @\"\"];"
73+
"GMSServices.provideAPIKey(Bundle.main.object(forInfoDictionaryKey: \"GoogleMapsApiKey\") as? String ?? \"\")"
9274
]
9375
},
9476
"pods": {

ios/AppDelegate.swift

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
import MendixNative
22

33
@UIApplicationMain
4-
class AppDelegate: ReactAppProvider, UNUserNotificationCenterDelegate {
4+
class AppDelegate: ReactAppProvider {
55

66
var shouldOpenInLastApp = false
77
var hasHandledLaunchAppWithOptions = false
88

99
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
1010

11-
setupApp(application: application, launchOptions: launchOptions)
12-
MendixAppDelegate.delegate = self
13-
UNUserNotificationCenter.current().delegate = self
1411
MendixAppDelegate.application(application, didFinishLaunchingWithOptions: launchOptions)
15-
12+
setupApp(application: application, launchOptions: launchOptions)
1613
changeRoot(to: UIViewController())
1714

1815
guard let url = Bundle.main.object(forInfoDictionaryKey: "Runtime url") as? String, !url.isEmpty else {
@@ -58,8 +55,4 @@ class AppDelegate: ReactAppProvider, UNUserNotificationCenterDelegate {
5855
func getWarningFilterValue() -> WarningsFilter {
5956
return .none
6057
}
61-
62-
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
63-
MendixAppDelegate.userNotificationCenter(center, willPresentNotification: notification, withCompletionHandler: completionHandler)
64-
}
6558
}

ios/Dev/AppDelegate.swift

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ import Foundation
22
import MendixNative
33

44
@UIApplicationMain
5-
class AppDelegate: ReactAppProvider, UNUserNotificationCenterDelegate {
5+
class AppDelegate: ReactAppProvider {
66

77
var shouldOpenInLastApp = false
88
var hasHandledLaunchAppWithOptions = false
99

1010
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
11-
setupApp(application: application, launchOptions: launchOptions)
12-
MendixAppDelegate.delegate = self
13-
UNUserNotificationCenter.current().delegate = self
11+
1412
MendixAppDelegate.application(application, didFinishLaunchingWithOptions: launchOptions)
13+
setupApp(application: application, launchOptions: launchOptions)
1514

1615
IQKeyboardManager.shared().isEnabled = false
1716

@@ -22,10 +21,6 @@ class AppDelegate: ReactAppProvider, UNUserNotificationCenterDelegate {
2221
return true
2322
}
2423

25-
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
26-
MendixAppDelegate.userNotificationCenter(center, willPresentNotification: notification, withCompletionHandler: completionHandler)
27-
}
28-
2924
func getWarningFilterValue() -> WarningsFilter {
3025
#if DEBUG
3126
return .all

ios/MendixAppDelegate.swift

Lines changed: 0 additions & 42 deletions
This file was deleted.

ios/mendix_utils.rb

Lines changed: 24 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,7 @@ def generate_mendix_delegate
3737
imports = []
3838
hooks = {
3939
didFinishLaunchingWithOptions: [],
40-
didReceiveLocalNotification: [],
41-
didReceiveRemoteNotification: [],
42-
didRegisterUserNotificationSettings: [],
4340
openURL: [],
44-
willPresentNotification: [],
45-
didReceiveNotificationResponse: [],
4641
getJSBundleFile: [],
4742
}
4843

@@ -77,72 +72,42 @@ def generate_mendix_delegate
7772
end
7873
end
7974

80-
File.open("MendixAppDelegate.m", "w") do |file|
75+
File.open("MendixAppDelegate.swift", "w") do |file|
8176
mendix_app_delegate = mendix_app_delegate_template.sub("{{ imports }}", stringify(imports))
8277
hooks.each { |name, hook| mendix_app_delegate.sub!("{{ #{name.to_s} }}", stringify(hook)) }
83-
returnHooks.each { |name, hook| mendix_app_delegate.sub!("{{ #{name.to_s} }}", stringify(hook).length > 0 ? stringify(hook) : " return YES;") }
78+
returnHooks.each { |name, hook| mendix_app_delegate.sub!("{{ #{name.to_s} }}", stringify(hook).length > 0 ? stringify(hook) : " return true") }
8479
file << mendix_app_delegate
8580
end
8681
end
8782

8883
def mendix_app_delegate_template
8984
%(// DO NOT EDIT BY HAND. THIS FILE IS AUTO-GENERATED
90-
#import <Foundation/Foundation.h>
91-
#import <MendixNative.h>
92-
#import "MendixAppDelegate.h"
85+
import Foundation
86+
import MendixNative
9387
{{ imports }}
9488
95-
@implementation MendixAppDelegate
96-
97-
static UIResponder<UIApplicationDelegate, UNUserNotificationCenterDelegate> *_Nullable delegate;
98-
99-
+ (void) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
100-
{{ didFinishLaunchingWithOptions }}
101-
}
102-
103-
+ (void) application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
104-
{{ didReceiveLocalNotification }}
105-
}
106-
107-
+ (void) application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
108-
fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
109-
{{ didReceiveRemoteNotification }}
110-
}
111-
112-
+ (void) application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
113-
{{ didRegisterUserNotificationSettings }}
114-
}
115-
116-
+ (BOOL) application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
117-
{{ boolean_openURLWithOptions }}
118-
}
119-
120-
+ (void) application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
121-
{{ openURL }}
122-
}
123-
124-
+ (void) userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
125-
{{ willPresentNotification }}
126-
}
127-
128-
+ (void) userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler {
129-
{{ didReceiveNotificationResponse }}
130-
}
131-
132-
+ (UIResponder<UIApplicationDelegate, UNUserNotificationCenterDelegate> *_Nullable) delegate {
133-
return delegate;
134-
}
135-
136-
+ (void) setDelegate:(UIResponder<UIApplicationDelegate, UNUserNotificationCenterDelegate> *_Nonnull)value {
137-
delegate = value;
138-
}
89+
/// Auto-generated implementation of MendixAppDelegate
90+
/// Generated based on enabled capabilities in capabilities.ios.json
91+
class MendixAppDelegate: NSObject {
92+
93+
static func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) {
94+
{{ didFinishLaunchingWithOptions }}
95+
}
13996
140-
+ (NSURL *) getJSBundleFile {
141-
{{ getJSBundleFile }}
142-
return [ReactNative.instance getJSBundleFile];
97+
static func application(_ application: UIApplication, openURL url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
98+
{{ boolean_openURLWithOptions }}
99+
}
100+
101+
static func application(_ application: UIApplication, openURL url: URL, sourceApplication: String?, annotation: Any) {
102+
{{ openURL }}
103+
}
104+
105+
static func getJSBundleFile() -> URL? {
106+
{{ getJSBundleFile }}
107+
return BundleHelper.getJSBundleFile()
108+
}
143109
}
144-
145-
@end\n)
110+
)
146111
end
147112

148113
def stringify(array)

0 commit comments

Comments
 (0)