Skip to content

Commit 54275c4

Browse files
committed
Initial commit (not tested so far)
1 parent 33e1706 commit 54275c4

8 files changed

+142
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

README.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
11
# cordova-plugin-wkwebview-cookie-sync
2-
An alternative way to sync cookies for a wkWebView
2+
3+
While this plugin has not been tested properly so far it should provide an alternative way to sync cookies in a wkWebView implemantation.
4+
5+
This is necessary as cookies may not get synced properly on the very first start of the app.
6+
7+
## Usage
8+
9+
```
10+
document.addEventListener('deviceready', () => {
11+
const args = ['GET', 'https://my.site.com'];
12+
cordova.exec(null, null, 'WKWebViewSyncCookies', 'sync', args);
13+
});
14+
```

package.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "cordova-plugin-wkwebview-cookie-sync",
3+
"description": "Cordova plugin to sync cookies in a WKWebView",
4+
"version": "1.0.0",
5+
"author": "Christian-W. Budde <[email protected]>",
6+
"bugs": {
7+
"url": "https://github.com/CWBudde/cordova-plugin-wkwebview-cookie-sync/issues"
8+
},
9+
"cordova": {
10+
"id": "cordova-plugin-wkwebview-cookie-sync",
11+
"platforms": [
12+
"ios"
13+
]
14+
},
15+
"homepage": "https://github.com/CWBudde/cordova-plugin-wkwebview-cookie-sync#readme",
16+
"keywords": [
17+
"cookies",
18+
"cordova",
19+
"ecosystem:cordova",
20+
"first",
21+
"get",
22+
"init",
23+
"install",
24+
"plugin",
25+
"sync",
26+
"wkwebview"
27+
],
28+
"license": "Unlicense",
29+
"main": "index.js",
30+
"repository": {
31+
"type": "git",
32+
"url": "git+https://github.com/psirenny/cordova-plugin-wkwebview-cookie-sync.git"
33+
},
34+
}

plugin.xml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version='1.0' encoding='utf-8'?>
2+
<plugin id="cordova-plugin-wkwebview-cookie-sync" version="1.0.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
3+
<name>WKWebViewCookieSync</name>
4+
<description>An alternative way to sync cookies for a wkWebView browser</description>
5+
<license>Apache 2.0</license>
6+
<keywords>cordova,wkwebview,cookies,first</keywords>
7+
<engines>
8+
<engine name="cordova" version=">=6.0.0" />
9+
<engine name="cordova-ios" version=">=4.0.0" />
10+
</engines>
11+
<platform name="ios">
12+
<config-file target="config.xml" parent="/*">
13+
<feature name="WKWebViewCookieSync">
14+
<param name="ios-package" value="WKWebViewCookieSync" />
15+
</feature>
16+
</config-file>
17+
<repo>https://github.com/CWBudde/cordova-plugin-wkwebview-cookie-sync.git</repo>
18+
<js-module src="www/cookiesync.js" name="cookiesync">
19+
<clobbers target="wkwebview" />
20+
</js-module>
21+
<header-file src="src/ios/WKWebViewCookieSync.h" />
22+
<source-file src="src/ios/WKWebViewCookieSync.m" />
23+
</platform>
24+
</plugin>

src/WKWebViewCookieSync.h

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2018 Christian-W. Budde
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import <Cordova/CDV.h>
18+
19+
@interface WKWebViewCookieSync : CDVPlugin
20+
21+
- (void)sync:(CDVInvokedUrlCommand *)command;
22+
23+
@property (nonatomic, strong) NSString* callbackId;
24+
25+
@end

src/ios/WKWebViewCookieSync.h

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#import <Cordova/CDV.h>
2+
3+
@interface WKWebViewCookieSync : CDVPlugin
4+
5+
- (void)sync:(CDVInvokedUrlCommand *)command;
6+
7+
@end

src/ios/WKWebViewCookieSync.m

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#import "WKWebViewCookieSync.h"
2+
#import <Cordova/CDV.h>
3+
4+
@implementation WKWebViewCookieSync
5+
6+
- (void)sync:(CDVInvokedUrlCommand *)command {
7+
self.CallbackId = command.callbackId;
8+
NSLog(@"Test");
9+
10+
self.webView.configuration.processPool = [[WKProcessPool alloc] init];
11+
12+
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.CallbackId];
13+
}
14+
15+
@end

www/cookiesync.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2017 Christian-W. Budde
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
var exec = require('cordova/exec');
18+
19+
module.exports = {
20+
cookieSync: function (successCallback, errorCallback) {
21+
exec(successCallback, errorCallback, 'WKWebViewCookieSync', 'sync', []);
22+
}
23+
};

0 commit comments

Comments
 (0)