10
10
#import < React/RCTBridge.h>
11
11
#import < React/RCTEventDispatcher.h>
12
12
#import < React/RCTUtils.h>
13
+ #import < React/RCTLog.h>
13
14
14
15
static NSString *const kOpenURLNotification = @" RCTOpenURLNotification" ;
15
16
@@ -97,7 +98,18 @@ - (void)handleOpenURLNotification:(NSNotification *)notification
97
98
if (success) {
98
99
resolve (@YES );
99
100
} else {
100
- reject (RCTErrorUnspecified, [NSString stringWithFormat: @" Unable to open URL: %@ " , URL], nil );
101
+ #if TARGET_OS_SIMULATOR
102
+ // Simulator-specific code
103
+ if ([URL.absoluteString hasPrefix: @" tel:" ]){
104
+ RCTLogWarn (@" Unable to open the Phone app in the simulator for telephone URLs. URL: %@ " , URL);
105
+ resolve (@NO );
106
+ } else {
107
+ reject (RCTErrorUnspecified, [NSString stringWithFormat: @" Unable to open URL: %@ " , URL], nil );
108
+ }
109
+ #else
110
+ // Device-specific code
111
+ reject (RCTErrorUnspecified, [NSString stringWithFormat: @" Unable to open URL: %@ " , URL], nil );
112
+ #endif
101
113
}
102
114
}];
103
115
} else {
@@ -107,7 +119,18 @@ - (void)handleOpenURLNotification:(NSNotification *)notification
107
119
if (opened) {
108
120
resolve (@YES );
109
121
} else {
110
- reject (RCTErrorUnspecified, [NSString stringWithFormat: @" Unable to open URL: %@ " , URL], nil );
122
+ #if TARGET_OS_SIMULATOR
123
+ // Simulator-specific code
124
+ if ([URL.absoluteString hasPrefix: @" tel:" ]){
125
+ RCTLogWarn (@" Unable to open the Phone app in the simulator for telephone URLs. URL: %@ " , URL);
126
+ resolve (@NO );
127
+ } else {
128
+ reject (RCTErrorUnspecified, [NSString stringWithFormat: @" Unable to open URL: %@ " , URL], nil );
129
+ }
130
+ #else
131
+ // Device-specific code
132
+ reject (RCTErrorUnspecified, [NSString stringWithFormat: @" Unable to open URL: %@ " , URL], nil );
133
+ #endif
111
134
}
112
135
#endif
113
136
}
0 commit comments