「Xamarin.Mac/カスタムURLスキームを利用する」を編集中
この編集を取り消せます。 下記の差分を確認して、本当に取り消していいか検証してください。よろしければ変更を保存して取り消しを完了してください。
最新版 | 編集中の文章 | ||
1行目: | 1行目: | ||
− | [[Xamarin. | + | [[Xamarin.Ma]]cで[[カスタムURLスキーム]]を使いたい。 |
− | |||
− | |||
== 実装 == | == 実装 == | ||
− | |||
以下でカスタムURLスキームが利用可能になる。 | 以下でカスタムURLスキームが利用可能になる。 | ||
− | # | + | # Xamarin Studioでプロジェクト内の「Info.plist」を開く |
# 下部の「Advanced」タブを開く | # 下部の「Advanced」タブを開く | ||
# URL Typesの「Add URL Type」ボタンを押す | # URL Typesの「Add URL Type」ボタンを押す | ||
− | |||
# 「Identifier」は何でもよい。アプリのIdentifierでも入れておく。 | # 「Identifier」は何でもよい。アプリのIdentifierでも入れておく。 | ||
# 「URL Schems」にURLスキーム名を入れる(例:monobook) | # 「URL Schems」にURLスキーム名を入れる(例:monobook) | ||
− | + | 次にURLスキームが叩かれた際に呼ばれるメソッドの登録と実装をする。 | |
− | |||
<source lang="csharp"> | <source lang="csharp"> | ||
using System; | using System; | ||
36行目: | 31行目: | ||
{ | { | ||
// URLスキームで呼ばれるメソッドを指定する。 | // URLスキームで呼ばれるメソッドを指定する。 | ||
− | |||
var appleEventManager = NSAppleEventManager.SharedAppleEventManager; | var appleEventManager = NSAppleEventManager.SharedAppleEventManager; | ||
appleEventManager.SetEventHandler(this | appleEventManager.SetEventHandler(this | ||
64行目: | 58行目: | ||
; | ; | ||
− | |||
Console.WriteLine(parameters); | Console.WriteLine(parameters); | ||
} | } | ||
/// <summary> | /// <summary> | ||
− | + | /// Xamarin.Macに定数らしきものが見当たらなかったので作った | |
− | /// Xamarin. | ||
/// </summary> | /// </summary> | ||
public static class AEKeyword | public static class AEKeyword | ||
96行目: | 88行目: | ||
</source> | </source> | ||
− | + | ターミナルでopenを叩けば簡単に[[デバッグ]]できる。openの引数(URLスキーム)にアンパサンド(&)を含む場合はダブルクォーテーション(")で囲むこと。 | |
− | |||
open "monobook://" | open "monobook://" | ||
open "monobook://inbox" | open "monobook://inbox" | ||
104行目: | 95行目: | ||
== 関連項目 == | == 関連項目 == | ||
− | |||
== 参考文献 == | == 参考文献 == |