0

i build an App with ionic 2 and open specific Attachments-Files from Outlook or GMAIL wit this App. I specify the following in the Manifest.XML:

<intent-filter>
       <action android:name="android.intent.action.VIEW" />
       <category android:name="android.intent.category.DEFAULT" />
       <category android:name="android.intent.category.BROWSABLE" />
       <data android:mimeType="*/*" />
       <data android:pathPattern="*.*\\.yxc" />
</intent-filter>
<intent-filter>
       <action android:name="android.intent.action.VIEW" />
       <category android:name="android.intent.category.DEFAULT" />
       <category android:name="android.intent.category.BROWSABLE" />
       <data android:scheme="file" />
       <data android:mimeType="*/*" />
       <data android:host="*" />
       <data android:pathPattern=".*\\.yxc" />
</intent-filter>

And in my app.component.ts i get with:

window['plugins'].intentShim.getIntent(
  function(intent)
  {
    console.log(intent);

  },
  function()
  {
    console.log('Error getting launch intent');
  });

the following Path to the File:

content://com.microsoft.office.outlook.fileprovider/outlookfile/data/data/com.microsoft.office.outlook/app_1-MD5-328ccc4a44361ab118f13f707dc9609b/FileName.yxc

But how can i handle this File and Path?

hydrococcus
  • 414
  • 2
  • 5
  • 20

1 Answers1

0

Here is my solution:

if (pathName.startsWith('content://')) {

this.filePath.resolveNativePath(InfoIQO.path)
    .then((result) => {

        let resultPath = result.substr(0, result.lastIndexOf('/'));
        let resultFilename = result.substr(result.lastIndexOf('/') + 1, result.length);

        this.readAsBinaryFile(resultPath, resultFilename);
        loader.dismiss();

    })
    .catch((error) => {
        console.log(error);
    })

}

readAsBinaryFile(path: string, file: string) {

    this.file.readAsBinaryString(path, file)
        .then((binaryContent) => {

            console.log(binaryContent);
        .catch((error) => {
            console.log(error)
        })

}

inspired from: Phonegap: Resolving content:// URI obtained from native file chooser

hydrococcus
  • 414
  • 2
  • 5
  • 20