First of all you didn't share your entire function so I'm going to make some assumptions. According to their docs iOS has some quirks.
So first things first let's see what your error means. According to their docs:
If Facebook is not installed, the errorcallback will be invoked with message 'not available'
Conclusion: you either have the app not installed, or you're not using a prefix for iOS (read below)
Edit your config.xml
and add the following:
<platform name="ios">
<!-- add this entry -->
<config-file platform="ios" target="*-Info.plist" parent="LSApplicationQueriesSchemes">
<array>
<string>facebook</string>
<!-- ...... -->
<string>viber</string>
</array>
</config-file>
</platform>
To solve earlier said Quirk, also according to the docs, talking about shareVia
function quirks:
iOS: You are limited to 'com.apple.social.[facebook | twitter |
sinaweibo | tencentweibo]'. If an app does not exist, the
errorcallback is invoked and iOS shows a popup message asking the user
to configure the app.
This first of all means that, with this shareVia
function, you can only share to facebook, twitter, sinaweibo and tencentweibo (whatever those last 2 are)
Second of all it means that you need to add com.apple.social.
before the app
Basically setting prefix = this.platform.is('ios') ? 'com.apple.social.' : '';
and then using
import { Platform } from '@ionic-angular';
...
shareVia(app) {
// only prefix on ios
let prefix = this.platform.is('ios') ? 'com.apple.social.' : '';
// NOTE: canShareVia doesn't need the prefix!
this.canShareVia(app, .....).then(() => {
// shareVia *does* require the prefix on ios.
// This returns 'not available' if the first parameter provided doesn't match an *installed* app.
this.shareVia(prefix + app, .....)
})
}