Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use in ionic v2 & 3 #1

Open
leribol opened this issue Dec 5, 2017 · 3 comments
Open

use in ionic v2 & 3 #1

leribol opened this issue Dec 5, 2017 · 3 comments

Comments

@leribol
Copy link

leribol commented Dec 5, 2017

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

  • created an empty project with ionic,
  • add your plug in
  • build ios

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
Copy link
Owner

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
Copy link
Author

leribol commented Dec 6, 2017

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants