These are chat archives for angular/angular-2-ionic-2

6th
May 2018
Maek Twain
@maektwain
May 06 2018 16:07
Hey folks, i am trying to use this plugin https://github.com/EternallLight/cordova-plugin-openwith-ios
its getting installed but unable to use js code inside my app
any help? direction
UncertaintyP
@UncertaintyP
May 06 2018 16:10
What do you mean by unable to use js code inside my app
Maek Twain
@maektwain
May 06 2018 16:10
So, the above plugin has some js based configuration for the plugin
i am not able to use it says cordova not found, i am on typescript based ionic
UncertaintyP
@UncertaintyP
May 06 2018 16:11
Are you on device or in browser?
Maek Twain
@maektwain
May 06 2018 16:11
Right now, i am on the browser
but when doing on the device the app stucks does not go beyond platform.ready
UncertaintyP
@UncertaintyP
May 06 2018 16:12
There is no cordova in the browser :)
Maek Twain
@maektwain
May 06 2018 16:12
Yeah
True so do i test this in the device directly
UncertaintyP
@UncertaintyP
May 06 2018 16:13
or emulator
Maek Twain
@maektwain
May 06 2018 16:14
document.addEventListener('deviceready', setupOpenwith, false);

function setupOpenwith() {

  // Increase verbosity if you need more logs
  //cordova.openwith.setVerbosity(cordova.openwith.DEBUG);

  // Initialize the plugin
  cordova.openwith.init(initSuccess, initError);

  // Set logged in status
  cordova.openwith.setLoggedIn(true);

  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 URLs and text - actually the shared URL or text. For image - its base64 string representation.
      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
    // ...
  }
}
UncertaintyP
@UncertaintyP
May 06 2018 16:14
here is an example I use for a plugin: window.hasOwnProperty('cordova') && cordova.plugins.notification.local.fireQueuedEvents();so always check if cordova is available by either Ionics Platform or this snippet
Maek Twain
@maektwain
May 06 2018 16:14
for device?
Let me quickly check
for iOS it will be same
UncertaintyP
@UncertaintyP
May 06 2018 16:16
You would call setupOpenWith() in your this.platform.ready().then(() => {...}); block, also declare var cordova: any to silence typescript
Maek Twain
@maektwain
May 06 2018 16:25
 if (this.platform.is('cordova')) {
          setupOpenwith();
something like this
Its says cordova is no defined
Maek Twain
@maektwain
May 06 2018 16:35
It did something
Maek Twain
@maektwain
May 06 2018 16:58
Not working
Maek Twain
@maektwain
May 06 2018 22:28
Does Does ionic support open-with
kinda of functionality
cc.fovea.cordova.openwith
natively