Skip to content

Commit

Permalink
fix: ios app changes (#1136)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgithubprofile authored Nov 13, 2023
1 parent 187849a commit d504758
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 20,292 deletions.
19 changes: 1 addition & 18 deletions cordova/cc.fovea.cordova.openwith/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# cordova-plugin-openwith

<a elementsid="https://fovea.cc" href="https://fovea.cc"><img alt="Logo Fovea" src="https://fovea.cc/blog/wp-content/uploads/2017/09/fovea-logo-flat-128.png" height="50" /></a> &amp; <a elementsid="https://www.interactivetools.com" href="https://www.interactivetools.com"><img alt="Logo InteractiveTools" src="https://www.interactivetools.com/assets/images/header/logo.png" height="59" /></a>
<a href="https://fovea.cc"><img alt="Logo Fovea" src="https://fovea.cc/blog/wp-content/uploads/2017/09/fovea-logo-flat-128.png" height="50" /></a> &amp; <a href="https://www.interactivetools.com"><img alt="Logo InteractiveTools" src="https://www.interactivetools.com/assets/images/header/logo.png" height="59" /></a>

[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)

Expand Down Expand Up @@ -71,23 +71,6 @@ cordova plugin add cc.fovea.cordova.openwith \

It shouldn't be too hard. But just in case, I [posted a screencast of it](https://youtu.be/eaE4m_xO1mg).

### iOS Setup

After having installed the plugin, with the ios platform in place, 1 operation needs to be done manually: setup the App Group on both the Cordova App and the Share Extension.

1. open the **xcodeproject** for your application
1. select the root element of your **project navigator** (the left-side pane)
1. select the **target** of your application
1. select **capabilities**
1. scroll down to **App Groups**
1. make sure it's **ON**
1. create and activate an **App Group** called: `group.<YOUR_APP_BUNDLE_ID>.shareextension`
1. repeat the previous five steps for the **ShareExtension target**.

You might also have to select a Team for both the App and Share Extension targets, make sure to select the same.

Build, XCode might complain about a few things to setup that it will fix for you (creation entitlements files, etc).

### Advanced installation options

If you do not need anything fancy, you can skip this section.
Expand Down
6 changes: 3 additions & 3 deletions cordova/cc.fovea.cordova.openwith/hooks/iosAddTarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function getCordovaParameter(configXml, variableName) {
function getBundleId(context, configXml) {

return 'app.pocketnet'

var elementTree = require('elementtree');
var etree = elementTree.parse(configXml);
return etree.getroot().get('id');
Expand Down Expand Up @@ -380,11 +380,11 @@ module.exports = function (context) {

// Write the modified project back to disc
// console.log(' Writing the modified project back to disk...');
fs.writeFileSync(path.resolve(pbxProjectPath), pbxProject.writeSync());
fs.writeFileSync(pbxProjectPath, pbxProject.writeSync());
console.log('Added ShareExtension to XCode project');

deferral.resolve();
});

return deferral.promise;
};
};
3 changes: 2 additions & 1 deletion cordova/cc.fovea.cordova.openwith/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cc.fovea.cordova.openwith",
"version": "2.0.0",
"version": "2.1.0",
"description": "Cordova \"Open With\" plugin for iOS and Android",
"cordova": {
"id": "cc.fovea.cordova.openwith",
Expand Down Expand Up @@ -67,6 +67,7 @@
"src/android/cc/fovea/openwith/Serializer.java",
"src/ios/OpenWithPlugin.m",
"src/ios/ShareExtension/MainInterface.storyboard",
"src/ios/ShareExtension/ShareExtension-Entitlements.plist",
"src/ios/ShareExtension/ShareExtension-Info.plist",
"src/ios/ShareExtension/ShareViewController.h",
"src/ios/ShareExtension/ShareViewController.m",
Expand Down
2 changes: 1 addition & 1 deletion cordova/cc.fovea.cordova.openwith/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SOFTWARE.
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cc.fovea.cordova.openwith"
version="2.0.0">
version="2.1.0">

<name>OpenWith</name>
<description>Cordova "Open With" plugin for iOS and Android</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,7 @@ public static JSONArray itemsFromClipData(
final int clipItemCount = clipData.getItemCount();
JSONObject[] items = new JSONObject[clipItemCount];
for (int i = 0; i < clipItemCount; i++) {
if (clipData.getItemAt(i).getUri() != null) {
items[i] = toJSONObject(contentResolver, clipData.getItemAt(i).getUri());
} else if (clipData.getItemAt(i).getText() != null) {
items[i] = toJSONObject(contentResolver, clipData.getItemAt(i).getText().toString());
} else if (clipData.getItemAt(i).getHtmlText() != null) {
items[i] = toJSONObject(contentResolver, clipData.getItemAt(i).getHtmlText());
} else {
items[i] = toJSONObject(contentResolver, clipData.getItemAt(i).toString());
}
items[i] = toJSONObject(contentResolver, clipData.getItemAt(i).getUri());
}
return new JSONArray(items);
}
Expand Down Expand Up @@ -161,27 +153,6 @@ public static JSONObject toJSONObject(
return json;
}

/** Convert an String to JSON object.
*
* Object will include:
* "type" of data;
* "text" itself;
* "path" to the file, if applicable.
* "data" for the file.
*/
public static JSONObject toJSONObject(
final ContentResolver contentResolver,
final String text)
throws JSONException {
if (text == null) {
return null;
}
final JSONObject json = new JSONObject();
json.put("type", "text/plain");
json.put("text", text);
return json;
}

/** Return data contained at a given Uri as Base64. Defaults to null. */
public static String getDataFromURI(
final ContentResolver contentResolver,
Expand Down
Loading

0 comments on commit d504758

Please sign in to comment.