Skip to content

Commit

Permalink
UIWebView replaced with WKWebView
Browse files Browse the repository at this point in the history
  • Loading branch information
Tissot authored and Tissot committed Apr 20, 2020
1 parent 16faac5 commit b040278
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 21 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
[![Known Vulnerabilities](https://snyk.io/test/github/andrehtissot/cordova-plugin-fcm-with-dependecy-updated/badge.svg?targetFile=package.json)](https://snyk.io/test/github/andrehtissot/cordova-plugin-fcm-with-dependecy-updated?targetFile=package.json)
[![DeepScan grade](https://deepscan.io/api/teams/3417/projects/5068/branches/39495/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=3417&pid=5068&bid=39495)

### Version 4.6.4 (20/04/2020)

Replaced `UIWebView` with `WKWebView`, as required by Apple (https://developer.apple.com/documentation/uikit/uiwebview).

### Version 4.6.0 (04/04/2020) [DEPRECATED]

For the IOS, if app is on the foreground and the app receives a `data` push notification, the data can be retrieved by setting the callback to the new method: `FCMPlugin.onFirebaseDataNotificationIOS`.
Expand Down
2 changes: 1 addition & 1 deletion cordova-plugin-fcm-with-dependecy-updated.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |spec|
#

spec.name = "cordova-plugin-fcm-with-dependecy-updated"
spec.version = "4.6.3"
spec.version = "4.6.4"
spec.summary = "Google FCM Push Notifications Cordova Plugin"

# This description is used to generate tags and improve search results.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "4.6.3",
"version": "4.6.4",
"name": "cordova-plugin-fcm-with-dependecy-updated",
"cordova_name": "Cordova FCM Push Plugin",
"description": "Google Firebase Cloud Messaging Cordova Push Plugin fork with dependecy updated",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
specific language governing permissions and limitations
under the License.
-->
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="cordova-plugin-fcm-with-dependecy-updated" version="4.6.3">
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="cordova-plugin-fcm-with-dependecy-updated" version="4.6.4">
<name>Cordova FCM Push Plugin</name>
<description>Google Firebase Cloud Messaging Cordova Push Plugin fork with dependecy updated</description>
<license>MIT</license>
Expand Down
1 change: 1 addition & 0 deletions src/ios/FCMPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- (void)registerNotification:(CDVInvokedUrlCommand*)command;
- (void)notifyOfMessage:(NSData*) payload;
- (void)notifyOfFirebaseDataMessage:(NSData*) payload;
- (void)runJS:(NSString *)jsCode;
- (void)appEnterBackground;
- (void)appEnterForeground;

Expand Down
32 changes: 14 additions & 18 deletions src/ios/FCMPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#import "AppDelegate+FCMPlugin.h"
#import <UserNotifications/UserNotifications.h>
#import <Cordova/CDV.h>
#import <WebKit/WebKit.h>
#import "FCMPlugin.h"
#import "Firebase.h"

Expand Down Expand Up @@ -154,25 +155,15 @@ -(void) notifyOfMessage:(NSData *)payload
NSString *JSONString = [[NSString alloc] initWithBytes:[payload bytes] length:[payload length] encoding:NSUTF8StringEncoding];
NSString * notifyJS = [NSString stringWithFormat:@"%@(%@);", notificationCallback, JSONString];
NSLog(@"stringByEvaluatingJavaScriptFromString %@", notifyJS);

if ([self.webView respondsToSelector:@selector(stringByEvaluatingJavaScriptFromString:)]) {
[(UIWebView *)self.webView stringByEvaluatingJavaScriptFromString:notifyJS];
} else {
[self.webViewEngine evaluateJavaScript:notifyJS completionHandler:nil];
}
[self runJS:notifyJS];
}

-(void) notifyOfFirebaseDataMessage:(NSData *)payload
{
NSString *JSONString = [[NSString alloc] initWithBytes:[payload bytes] length:[payload length] encoding:NSUTF8StringEncoding];
NSString * notifyJS = [NSString stringWithFormat:@"%@(%@);", firebaseDataNotificationCallback, JSONString];
NSLog(@"stringByEvaluatingJavaScriptFromString %@", notifyJS);

if ([self.webView respondsToSelector:@selector(stringByEvaluatingJavaScriptFromString:)]) {
[(UIWebView *)self.webView stringByEvaluatingJavaScriptFromString:notifyJS];
} else {
[self.webViewEngine evaluateJavaScript:notifyJS completionHandler:nil];
}
[self runJS:notifyJS];
}

-(void) notifyFCMTokenRefresh:(NSString *)token
Expand All @@ -181,12 +172,17 @@ -(void) notifyFCMTokenRefresh:(NSString *)token
fcmToken = token;
NSString * notifyJS = [NSString stringWithFormat:@"%@('%@');", tokenRefreshCallback, token];
NSLog(@"stringByEvaluatingJavaScriptFromString %@", notifyJS);

if ([self.webView respondsToSelector:@selector(stringByEvaluatingJavaScriptFromString:)]) {
[(UIWebView *)self.webView stringByEvaluatingJavaScriptFromString:notifyJS];
} else {
[self.webViewEngine evaluateJavaScript:notifyJS completionHandler:nil];
}
[self runJS:notifyJS];
}

- (void)runJS:(NSString *)jsCode {
dispatch_async(dispatch_get_main_queue(), ^{
if ([self.webView respondsToSelector:@selector(evaluateJavaScript:completionHandler:)]) {
[(WKWebView *)self.webView evaluateJavaScript:jsCode completionHandler:nil];
} else {
[self.webViewEngine evaluateJavaScript:jsCode completionHandler:nil];
}
});
}

-(void) appEnterBackground
Expand Down

0 comments on commit b040278

Please sign in to comment.