aliyome
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Ionic で作るモバイルアプリ ## はじめに このエントリは[Ionic で作る モバイルアプリ制作入門[Angular 版]<Web/iPhone/Android 対応> | 榊原昌彦](https://www.amazon.co.jp/gp/product/B081ZN64FM)を読みながら走り書きしたメモです。 私は Angular/TypeScript の初心者というわけでは無いので、これらに関する部分のメモは少なめです。 一方、iOS/Android 開発はずぶの素人なので、それらに関するメモが多めです。 ### 追記 各章メモでいくつか「疑問」を挙げていますが、ありがたいことに大部分はIonic本の著者様からご回答をいただきました。 [Ionic赤本への疑問がすごく鋭かったのでまとめて返事する記事 - Qiita](https://qiita.com/rdlabo/items/b380263e8b1b253c371b) ありがとうございます! ## 各章メモ ### 0. はじめに - Ionic を利用することで Mobile/Web で同じような UI/UX を実現出来る - Capacitor を利用することで iOS/Android アプリを作れる ### 1. Ionic - Ionic は WebComponents を採用しているため Angular に依存しない - Ionic は再利用可能な UI コンポーネント - iOS/Android で表示が異なる(プラットフォームに最適な表示がされる) - Ionic CLI `yarn global add ionic` ### 2. Ionic のはじめかた - プロジェクト作成: `ionic start --type angular` - 開発用サーバ起動(HMR): `ionic serve` - **iOS/Android のデザインプレビュー**: `ionic serve --lab` ![ionic serve --lab](https://i.imgur.com/4cs8t6S.png) - 拡張機能の追加: `ionic integrations enable capacitor # など` - yarn をデフォルトに: `ionic config set --global npmClient yarn` - Android 用プロジェクト生成: `ionic cap add android` ![android studioでエミュレータを起動](https://i.imgur.com/MT1IaT6.png) 疑問 - `ionic serve`と`ng serve`の違い - ログにこれが表示されてるから実態はこれだけかな? `ng.cmd run app:serve --host=localhost --port=8100` ### 3. Ionicの基本 - Angularアプリの基本に関する内容が多め - `<ion-title>hoge</ion-title>`: `<title>`の値を`hoge`に設定できる - `ionic g page task-list`: `ng g c` に加えて、遅延読み込みのモジュール生成と、ルーティングの生成を追加でやってくれる - Ionicが追加するライフサイクル - `ionViewWillEnter()`: ページが表示される**アニメーションが始まるとき** - `ionViewDidEnter()`: ページが表示される**アニメーションが終了したとき** - `ionViewWillLeave()`: ページから離脱・遷移する**アニメーションが始まるとき** - `ionViewDidLeave()`: ページから離脱する**アニメーションが終了したとき** 疑問 - Ionicのライフサイクルフック用のinterfaceは無いのかな? - `ngOnInit`等もinterfaceは必要ないけど、あった方がコードの見通しが良い ### 4. 外部リソースを使う - AngularのHttpClientの使い方に関する内容が多め - `<ion-skeleton-text>`: 最近のwebでよく見る本文ロード中はプレースホルダーが表示されるやつ - `this.platform.is('hybrid')`: コンポーネント等のロジックで、iOS/Android上で動作している場合`true` ### 5. コードリファクタリング - リファクタリングについての章 - Ionicのライフサイクルフックはカスタムコンポーネントでは動かない - Ionicではinterfaceの型にprefixとしてIをつける。例:`interface IPost {}` - MSっぽい。好みではない。 - Ionic公式の[カラージェネレーター](https://ionicframework.jp/docs/theming/color-generator/) がテーマ全体の色変更に便利に使える - Ionicの各コンポーネントのCSSは`--background`等の変数を持っている。各コンポーネントはShadowDOMでカプセル化されているため、CSSのスタイリングはこの変数を通して行う。 - 例: [ion-button CSSカスタム変数](https://ionicframework.jp/docs/api/button#css-custom-properties) - なるほどなぁ。これは便利。 疑問 - Ionicのライフサイクルフックが動く詳細な条件は? ### 6. Capacitor - Cordovaの*スピリチュアルな後継ライブラリ* - スピリチュアルとは? - Cordovaはconfig.xml経由でネイティブコードを生成するのに対して、Capacitorはネイティブコードを直接操作できる - React Nativeとの違いはNativeとHybridの違い - Capacitor NativeとかCapacitor Native for Webとかの謎プロダクトが作られて欲しい - capacitor.config.json: AppStore/GooglePlay 配布用設定などはこのファイル - [Configuring Your App - Capacitor](https://capacitor.ionicframework.com/docs/basics/configuring-your-app/#common-configuration) - `cordova-res`でmanifestやsplash用の画像パターンを生成できる - iconの差し替えは AndroidStudio の Image Asset 機能で行う - splashの差し替えはpng画像を差し替えるだけ - `app/src/main/AndroidManifest.xml`で、クリアテキストのパーミッションを許可しないと、AndroidシミュレータでLiveReloadできない - `android:usesCleartextTraffic="true"` - `ionic capacitor run android -l --address=0.0.0.0`: LiveReload - `Plugin.LocalNotifications`でローカル通知を送れる - [Local Notifications - Capacitor](https://capacitor.ionicframework.com/docs/apis/local-Notifications/) - `ionic cap copy` でiOS/Androidビルド用にファイルをコピー - `ionic cap sync` でiOS/Androidビルド用にファイルをコピーと、プラグインのコピーとインストール - [rdlabo/capacitor-admob](https://github.com/rdlabo/capacitor-admob)を使ってAdMob(広告)を表示する方法 - [@ionic-native/badge](https://ionicframework.com/jp/docs/native/badge)を使ってバッジを表示する - 手元の環境だとバッジが表示されなかった。本にもAndroiは機種によっては表示されない、とあったのでとりあえずスルー - [@ionic/pwa-elements](https://capacitor.ionicframework.com/docs/pwa-elements/)を使ってカメラ撮影機能を実装する - 手元の環境だと、ブラウザで動かすと再撮影時にブラックアウトする。Androidシミュレータ上は問題なし macOS機を持っていないのでiOSアプリ開発の部分は読み飛ばした メモにまとまりが無いのであとで見直す 疑問 - `cordova-res`とは別に、`ionic cordova resources`というコマンドがあったので詳細を調べる - [ionic cordova resources - Ionic Framework 日本語ドキュメンテーション](https://ionicframework.com/jp/docs/cli/commands/cordova-resources) - クリアテキストのパーミッションとは? ### 7. チャットアプリ - 非同期処理(Promise, async/await, RxJS)について - firebaseのプロジェクト作成とAuthの設定 - `@angular/fire/auth-guard`に`AngularFireAuthGuard`というGuardが用意されていてとても便利 - `@ionic/angular`の`NavController`が画面遷移時のトランジションアニメーションをやってくれて便利 - ドキュメントが見つからない? - `IonContent`は`scrollToTop(100) // 100: duration [ms]`メソッドを持っているので便利に使えそう ![チャットアプリのキャプチャ](https://i.imgur.com/a9EpQE7.gif) [web](https://ionic-chat-tutorial.firebaseapp.com) 疑問 - `.toPromise(Promise)` このPromiseはなんだろう ### 8. 実践的 - AppStore/GooglePlayでのアプリリリースについて - リリースすることがあったら改めて読む ### リポジトリ タスクリスト https://github.com/aliyome/ionic-tasklist-tutorial WordpressのpublicAPIを利用したブログっぽいやつ https://github.com/aliyome/ionic-wp-tutorial ネイティブアプリ https://github.com/aliyome/ionic-native-tutorial チャットアプリ https://github.com/aliyome/ionic-chat-tutorial

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully