Actions
cordova-plugin-openwith-ios¶
- Cordova create
> cordova create sharetest com.test.sharetest ShareTest
Creating a new cordova project.
> cd sharetest
- Platform add
> cordova platform add ios
Using cordova-fetch for cordova-ios@^6.2.0
Adding ios project...
Creating Cordova project for the iOS platform:
Path: platforms/ios
Package: com.test.sharetest
Name: ShareTest
iOS project created with cordova-ios@6.2.0
- Plugin add
> cordova plugin add cordova-plugin-openwith-ios --variable IOS_URL_SCHEME=openwith
Installing "cordova-plugin-openwith-ios" for ios
Installing "cordova-plugin-openwith-ios" dependencies
Copying "cordova-plugin-openwith-ios/ShareExtension" to ios...
Adding target "cordova-plugin-openwith-ios/ShareExtension" to XCode project
- Folder containing your iOS project: /Users/ryu/work/travelcoop/sharetest/platforms/ios/
Parsing existing project at location: /Users/ryu/work/travelcoop/sharetest/platforms/ios/ShareTest.xcodeproj/project.pbxproj...
ShareExtension group already exists.
Added ShareExtension to XCode project
Adding cordova-plugin-openwith-ios to package.json
> cordova prepare
~~~
- Open xcode
open platforms/ios/ShareTest.xcworkspace
- Xcode > Signing & Capabilities > Add "App Group"





- Select team

- Codova run
cordova run ios
- Simualtor

- Edit test code (./www/js/index.js)
``` javascript
// Increase verbosity if you need more logs
//cordova.openwith.setVerbosity(cordova.openwith.DEBUG);
// Initialize the plugin
cordova.openwith.init(initSuccess, initError);
function initSuccess() { console.log('init success!'); }
function initError(err) { console.log('init failed: ' + err); }
// Define your file handler
cordova.openwith.addHandler(myHandler);
function myHandler(intent) {
console.log('intent received');
console.log(' text: ' + intent.text); // description to the sharing, for instance title of the page when shared URL from Safari
for (var i = 0; i < intent.items.length; ++i) {
var item = intent.items[i];
console.log(' type: ', item.uti); // UTI. possible values: public.url, public.text or public.image
console.log(' type: ', item.type); // Mime type. For example: "image/jpeg"
console.log(' data: ', item.data); // shared data. For text, it is the shared text string. For files, the file's URL on the device file system. You can read it from the webview with cordova-plugin-file or window.Ionic.WebView.convertFileSrc.
console.log(' text: ', item.text); // text to share alongside the item. as we don't allow user to enter text in native UI, in most cases this will be empty. However for sharing pages from Safari this might contain the title of the shared page.
console.log(' name: ', item.name); // suggested name of the image. For instance: "IMG_0404.JPG"
console.log(' utis: ', item.utis); // some optional additional info
}
// ...
// Here, you probably want to do something useful with the data
// ...
}
- Codova run
> cordova run ios
- Check consol log (Safari Web Inspector)

류창균이(가) 3년 이상 전에 변경 · 2 revisions