Skip to content

Commit

Permalink
Merge pull request #6 from WebEngage/hotfix/webViewDependencyFix
Browse files Browse the repository at this point in the history
Reviewed: Remove UIWebView type check
  • Loading branch information
shadowTech827 authored Jun 3, 2021
2 parents 5dd860a + 40a7e55 commit ede3cca
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-webengage",
"version": "1.0.0",
"version": "1.0.1",
"description": "WebEngage Plugin that integrates with WebEngage native SDKs(Android & iOS) to provide engagement capabilities for hybrid applications built with PhoneGap/Cordova",
"main": "WebEngagePlugin.js",
"dependencies": {
Expand All @@ -25,11 +25,11 @@
"engagement",
"notifications"
],
"author": "arpit@webklipper.com",
"author": "mobile@webengage.com",
"license": "ISC",
"engines": {
"cordovaDependencies": {
"0.0.1": { "cordova-ios": ">=4.0.0", "cordova-android": ">=4.1.0"}
}
"cordovaDependencies": {
"1.0.0": {"cordova-ios": ">=4.0.0", "cordova-android": ">=4.1.0" }
}
}
}
}
9 changes: 9 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@
<source-file src="src/ios/WebEngagePlugin.m" />
<header-file src="src/ios/AppDelegate+WebEngagePlugin.h" />
<source-file src="src/ios/AppDelegate+WebEngagePlugin.m" />

<podspec>
<config>
<source url="https://github.com/CocoaPods/Specs.git"/>
</config>
<pods use-frameworks="true">
<pod name="WebEngage" spec="~> 5.2.6" />
</pods>
</podspec>
</platform>

<platform name="android">
Expand Down
14 changes: 2 additions & 12 deletions src/ios/WebEngagePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,7 @@ - (void)notification:(NSMutableDictionary *)inAppNotificationData
+ (NSString *)evaluateJavaScript:(NSString *)script onWebView:(UIView *)webView {
__block NSString* resultData = [[NSString alloc] init];

if ([webView isKindOfClass:UIWebView.class]) {
UIWebView *webview = (UIWebView*)webView;
resultData=[webview stringByEvaluatingJavaScriptFromString:script];
}

else if ([webView isKindOfClass:WKWebView.class]) {
if ([webView isKindOfClass:WKWebView.class]) {
WKWebView *webview = (WKWebView*)webView;
[webview evaluateJavaScript:script completionHandler:^(id _Nullable result, NSError * _Nullable error) {
resultData=result;
Expand All @@ -435,12 +430,7 @@ + (NSString *)evaluateJavaScript:(NSString *)script onWebView:(UIView *)webView
+ (void) evaluateJavaScript:(NSString *)script onWebView:(id)webView
completionHandler:(void (^ _Nullable)(NSString * _Nullable response, NSError * _Nullable error))completionHandler {

if ([webView isKindOfClass:UIWebView.class]) {
UIWebView *webview = (UIWebView*)webView;
NSString *response = [webview stringByEvaluatingJavaScriptFromString:script];
if (completionHandler)
completionHandler(response, nil);
} else if ([webView isKindOfClass:WKWebView.class]) {
if ([webView isKindOfClass:WKWebView.class]) {
WKWebView *webview = (WKWebView*)webView;
[webview evaluateJavaScript:script completionHandler:^(id result, NSError *error) {
if (completionHandler) {
Expand Down

0 comments on commit ede3cca

Please sign in to comment.