差分

提供: fukudat.net
ナビゲーションに移動検索に移動
1,580 バイト追加 、 2020年12月9日 (水) 01:41
NativeScript はkクロスプラットフォーム はクロスプラットフォーム (iOS と Android) のアプリケーションを構築するフレームワーク。
HTML, CSS, JavaScript を使用して OS native の API にアクセスする。[[Category:How-To]]
インストール方法を含めて、ドキュメントは 公式ドキュメントは https://docs.nativescript.org/ にある。
== [https://play.nativescript.org/ NativeScript Playground] ==
== CLI (コマンドラインインターフェイス) ==
=== インストール ===
Xcode に依存しているので、あらかじめ App Store から Xcode をインストールしておく。
 
cocoapods, xcodeproj に依存しているので、インストールする。
<pre>
$ sudo gem install cocoapods xcodeproj
</pre>
 
node.js に依存しているので、node.js をインストールする。
Mac の場合は、[[homebrew]] を使って、
いろいろ試したが、次のようにやったらうまくいった。
 
App_Resources/iOS/build.xcconfig に以下の2行を追加。
<pre>
PROVISIONING_PROFILE = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx;
PROVISIONING_PROFILE_SPECIFIER = <distribution-profile-name>;
</pre>
<pre>
$ tns publish ios --provision xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --appleApplicationSpecificPassword xxxx-xxxx-xxxx-xxxx
入力を迷った項目:
* 暗号を使うか? = REST API を https で読んでいるので、yes。ただし、https で呼んでいるので、yes。ただし、https のみを使用にチェック。
* IDFAを使うか? = 広告を表示するので (自分は使わないが) 広告配信サービスが使うだろうから yes。
== Plugin ==
 
=== Geolocation Plugin ===
 
==== インストール ====
<pre>
$ tns plugin add nativescript-geolocation
</pre>
 
==== 使い方 ====
https://github.com/NativeScript/nativescript-geolocation 参照
=== NativeScript Plugin for Google Maps ===
</pre>
これを呼び出すと interstitial (区切りの良いところで表示される全面広告) が表示される。
 
== Tips ==
=== スクリーンサイズを取得する ===
<pre>
import { screen } from "tns-core-modules/platform/platform";
...
some_method() {
console.log(`widthDIPs=${screen.mainScreen.widthDIPs}`);
console.log(`widthPixels=${screen.mainScreen.widthPixels}`);
console.log(`heightDIPs=${screen.mainScreen.heightDIPs}`);
console.log(`heightPixels=${screen.mainScreen.heightPixels}`);
console.log(`scale=${screen.mainScreen.scale}`);
}
</pre>
 
=== iconを使う ===
<pre>html
<Image src="font://&#xf5a0;" class="fas t-36">
<Label text="&#xf5a0;" class="fas t-36"/>
<Label [text]="text" class="fas t-36"/>
</pre>
 
iconを program から変更するには、3行目のパターン。ただし、text は <nowiki>&#xXXXX;</nowiki> は使えないので、次のように記述する。
 
<pre>typescript
text = String.fromCharCode(0xf5a0);
</pre>
 
icon のコードは https://fontawesome.com/icons?d=gallery で探す。
== 参考文献 ==

案内メニュー