Skip to content

Commit 2250a68

Browse files
committed
ZLPConstants: Return true in requiresMainQueueSetup
When writing the previous commit, I noticed that UIApplication comes from UIKit. React Native's doc makes it sound like we should return `true` here when our module "require[s] access to UIKit"; see code comment. (When this module first appeared, in 4828ecf, the comment correctly said that we didn't use UIKit. The use of UIApplication was added later, in 7471f6e.) I'm not aware of a functional change this would cause. The doc (https://reactnative.dev/docs/0.68/native-modules-ios#exporting-constants) says: > in the future your module may be initialized on a background > thread unless you explicitly opt out with > `+ requiresMainQueueSetup:` but (with "in the future") that doesn't sound like a behavior change we'd see now. Anyway, the features supported by this module (viewing a message list, and linking to system settings for Zulip notifications) still work fine, as tested manually on my iPhone 13 Pro running iOS 16.1.
1 parent e512d66 commit 2250a68

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

ios/ZulipMobile/ZLPConstants.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ import UIKit
33

44
@objc(ZLPConstants)
55
class ZLPConstants: NSObject {
6-
7-
86
// For why we include this, see
97
// https://reactnative.dev/docs/0.68/native-modules-ios#exporting-constants
108
@objc
119
static func requiresMainQueueSetup() -> Bool {
12-
// Initialization may be done on any thread; we don't need access to
13-
// UIKit.
14-
return false
10+
// UIApplication, which we use in `constantsToExport`, is provided by
11+
// UIKit. I think that means we should return `true` here. From the doc
12+
// linked above:
13+
// > If your module does not require access to UIKit, then you should
14+
// > respond to `+ requiresMainQueueSetup` with NO.
15+
return true
1516
}
1617

1718
@objc

0 commit comments

Comments
 (0)