Skip to content

Commit 48c6bae

Browse files
authored
Merge pull request #521 from Mailbutler/master
Use WKWebView instead of deprecated UIWebView
2 parents 6538fe2 + 8ad81a4 commit 48c6bae

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
1AF75EAF1E8569710097B315 /* NSString+OneSignal.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AF75EAD1E8567FD0097B315 /* NSString+OneSignal.m */; };
4141
1AF75EB01E8569720097B315 /* NSString+OneSignal.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AF75EAD1E8567FD0097B315 /* NSString+OneSignal.m */; };
4242
1AF75EB11E8569F60097B315 /* NSString+OneSignal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AF75EAC1E8567FD0097B315 /* NSString+OneSignal.h */; };
43+
1F047020231A4D29002725D4 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F04701F231A4D29002725D4 /* WebKit.framework */; };
44+
1F047021231A4D34002725D4 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F04701F231A4D29002725D4 /* WebKit.framework */; };
45+
1F047022231A4D3E002725D4 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F04701F231A4D29002725D4 /* WebKit.framework */; };
4346
37E6B2BB19D9CAF300D0C601 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 37E6B2BA19D9CAF300D0C601 /* UIKit.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
4447
3E464ED71D88ED1F00DCF7E9 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 37E6B2BA19D9CAF300D0C601 /* UIKit.framework */; };
4548
3E66F5821D90A2C600E45A01 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E08E2701D49A5C8002176DE /* SystemConfiguration.framework */; };
@@ -221,6 +224,7 @@
221224
03389F681FB548A0006537F0 /* OneSignalTrackFirebaseAnalyticsOverrider.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OneSignalTrackFirebaseAnalyticsOverrider.m; sourceTree = "<group>"; };
222225
1AF75EAC1E8567FD0097B315 /* NSString+OneSignal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+OneSignal.h"; sourceTree = "<group>"; };
223226
1AF75EAD1E8567FD0097B315 /* NSString+OneSignal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+OneSignal.m"; sourceTree = "<group>"; };
227+
1F04701F231A4D29002725D4 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
224228
37747F9319147D6500558FAD /* libOneSignal.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libOneSignal.a; sourceTree = BUILT_PRODUCTS_DIR; };
225229
37E6B2BA19D9CAF300D0C601 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
226230
3E08E2701D49A5C8002176DE /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
@@ -351,6 +355,7 @@
351355
isa = PBXFrameworksBuildPhase;
352356
buildActionMask = 2147483647;
353357
files = (
358+
1F047022231A4D3E002725D4 /* WebKit.framework in Frameworks */,
354359
37E6B2BB19D9CAF300D0C601 /* UIKit.framework in Frameworks */,
355360
);
356361
runOnlyForDeploymentPostprocessing = 0;
@@ -359,6 +364,7 @@
359364
isa = PBXFrameworksBuildPhase;
360365
buildActionMask = 2147483647;
361366
files = (
367+
1F047021231A4D34002725D4 /* WebKit.framework in Frameworks */,
362368
3E66F5821D90A2C600E45A01 /* SystemConfiguration.framework in Frameworks */,
363369
3E464ED71D88ED1F00DCF7E9 /* UIKit.framework in Frameworks */,
364370
91719A9C1E80839500DBE43C /* UserNotifications.framework in Frameworks */,
@@ -369,6 +375,7 @@
369375
isa = PBXFrameworksBuildPhase;
370376
buildActionMask = 2147483647;
371377
files = (
378+
1F047020231A4D29002725D4 /* WebKit.framework in Frameworks */,
372379
911E2CC81E399834003112A4 /* UserNotifications.framework in Frameworks */,
373380
911E2CC61E398B97003112A4 /* UIKit.framework in Frameworks */,
374381
911E2CC51E398B53003112A4 /* SystemConfiguration.framework in Frameworks */,
@@ -403,6 +410,7 @@
403410
37747F9519147D6500558FAD /* Frameworks */ = {
404411
isa = PBXGroup;
405412
children = (
413+
1F04701F231A4D29002725D4 /* WebKit.framework */,
406414
911E2CC71E399834003112A4 /* UserNotifications.framework */,
407415
3E464ED91D88EE6A00DCF7E9 /* Foundation.framework */,
408416
3E08E2701D49A5C8002176DE /* SystemConfiguration.framework */,

iOS_SDK/OneSignalSDK/Source/OneSignal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ typedef NS_ENUM(NSUInteger, OSNotificationDisplayType) {
133133
@property(readonly)NSString* subtitle;
134134
@property(readonly)NSString* body;
135135

136-
/* Web address to launch within the app via a UIWebView */
136+
/* Web address to launch within the app via a WKWebView */
137137
@property(readonly)NSString* launchURL;
138138

139139
/* Additional key value properties set within the payload */

iOS_SDK/OneSignalSDK/Source/OneSignalWebView.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@
2626
*/
2727

2828
#import <UIKit/UIKit.h>
29+
#import <WebKit/WebKit.h>
2930

30-
@interface OneSignalWebView : UIViewController <UIWebViewDelegate>
31+
@interface OneSignalWebView : UIViewController <WKNavigationDelegate>
3132

3233
@property(nonatomic, copy)NSURL *url;
33-
@property(nonatomic)UIWebView *webView;
34+
@property(nonatomic)WKWebView *webView;
3435
@property(nonatomic)UIActivityIndicatorView *uiBusy;
3536

3637
-(void)dismiss:(id)sender;

iOS_SDK/OneSignalSDK/Source/OneSignalWebView.m

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ @implementation OneSignalWebView
4242
-(void)viewDidLoad {
4343
[super viewDidLoad];
4444

45-
_webView = [UIWebView new];
46-
_webView.delegate = self;
45+
_webView = [WKWebView new];
46+
_webView.navigationDelegate = self;
4747
[self.view addSubview:_webView];
4848

4949
[self pinSubviewToMarginsWithSubview:_webView withSuperview:self.view];
@@ -73,17 +73,19 @@ -(void)dismiss:(id)sender {
7373
}];
7474
}
7575

76-
-(void)webViewDidStartLoad:(UIWebView *)webView {
76+
-(void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation {
7777
[_uiBusy startAnimating];
7878
}
7979

80-
-(void)webViewDidFinishLoad:(UIWebView *)webView {
81-
self.title = [_webView stringByEvaluatingJavaScriptFromString:@"document.title"];
82-
self.navigationController.title = self.title;
83-
[_uiBusy stopAnimating];
80+
-(void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
81+
[_webView evaluateJavaScript:@"document.title" completionHandler:^(id _Nullable result, NSError * _Nullable error) {
82+
self.title = result;
83+
self.navigationController.title = self.title;
84+
[_uiBusy stopAnimating];
85+
}];
8486
}
8587

86-
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
88+
-(void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error {
8789
[OneSignal onesignal_Log:ONE_S_LL_ERROR message:error.localizedDescription];
8890
}
8991

0 commit comments

Comments
 (0)