4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ionic Native の Social Sharingが、マルチバイト文字のパスの読み込みでうまくいかない件

4
Posted at

Ionic Nativeの便利な機能の1つにあるのが

Social Sharing
https://ionicframework.com/docs/native/social-sharing/

割と手間なくNativeのSNSシェア機能がIonicアプリから利用できます。

バグについて

画像を読み込ませるURLに日本語が入っている時、挙動が安定しなくなった。

this.socialShareing.share("こんにちは", "世界", "https://画像へのURL");

こんな感じでオーソドックスな使い方をしていたんですが、マルチバイトの文字列を含んだ画像のURLが読み込めないというエラーがiOSで出てきました。

そこで

let imageUrl = encodeURI("https://画像へのURL");

と、URLをエンコードして上げることにしました。この時点でiOSでは動く。

iOSを立てれば、Androidが立たず

iOSで動いたものの、今度はAndroidで動かなくなってしまった。
ので、Ionic の platformで場合分けして使ってあげることにしました。

let imageUrl = "https://画像へのURL";
if (this.platform.is('ios')) {
    imageUrl = encodeURI("https://画像へのURL");
}

以上。

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?