EternallLight / cordova-plugin-openwith-ios

A modified version of the Cordova iOS Share extension (cordova-plugin-openwith) by Jean-Christophe Hoelt for iOS. Supports receiving shared URLs, text and images as well as sharing several images at once.
https://web-mystery.com/
MIT License
28 stars 83 forks source link

use in ionic v2 & 3 #1

Open leribol opened 6 years ago

leribol commented 6 years ago

We want to achieve that (on ios); A user that views a web page on any browser in ios, hit share button, see out app and click it. After that, our app receives the url of the web page that user views (without any alert window etc..)

Up to now ( to check your plugin) We have

Finally, we have seen the app when we hit share button on safari.

However, for an ionic project, how we should modify your code (in usage part you wrote). I think we can not manage handler part.

You may see our version about handler part. And we can not see any alerts.

// Define your file handler window['plugins'].openwith.addHandler(myHandler);

function myHandler(intent) { alert('intent received'); alert(' 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]; alert(' type: ' + item.uti); // UTI. possible values: public.url, public.text or public.image alert(' type: ' + item.type); // Mime type. For example: "image/jpeg" alert(' data: ' + item.data); // shared data. For URLs and text - actually the shared URL or text. For image - its base64 string representation. alert(' 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. alert(' name: ' + item.name); // suggested name of the image. For instance: "IMG_0404.JPG" alert(' utis: ' + item.utis); // some optional additional info } // ... // Here, you probably want to do something useful with the data // ... }

Could you help us what we should do, or where we are making mistake.

Thank you.

EternallLight commented 6 years ago

Hello, A lot of the plugin has been rewritten since the last commit in this repo, including URL shares. Hopefully, I'll update it during the next weekend. For now, I recommend to inspect the data you receive in the handler, it should contain page URL and title (when shared from Safari), and adjust the handler body to your needs.

leribol commented 6 years ago

Thank you your reply. However, we could not get any data from handler, ie; we got "init alert" but we could not get any alert.

We built our project on ionic framework. May it be a problem.

Would you suggest anything about app.component.ts (root/src/app/..) constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) { platform.ready().then(() => { /////////////////////your suggestion ? }); }

maektwain commented 6 years ago

How do ,inspect the data within the app? I am also not wether its receiving data or not. How to check?