SlideShare a Scribd company logo
1 of 33
Download to read offline
Xamarin.Formsで
みんなでてんこ!
2015年10月3日
吉田 将明
第6回 Japan Xamarin User Group Conference @東京
先端技術事業部
All Rights Reserved. Copyright © CRESCO, LTD.
1
目次
自己紹介
みんなのてんこ 事例紹介
ソリューション概要
システム概要
開発環境、Framework
本アプリの特徴
Xamarin.Forms
Beacon部分とか
やってみての感想
簡単 正確
スピーディー
All Rights Reserved. Copyright © CRESCO, LTD.
2
自己紹介
吉田 将明(よしだ まさあき)
アプリケーションエンジニア
最近触ってる言語
C#,VB.NET,Objective-c,Node.js etc
兵庫県加古川育ち、東京でてきて3年目
SE→広告代理店営業→出戻りSE
All Rights Reserved. Copyright © CRESCO, LTD.
3
はじめに。。。
田淵さん、
XLSOFTさんHPへの事例掲載、
有難う御座います(´◉◞౪◟◉)ペコリ
ソリューション概要
All Rights Reserved. Copyright © CRESCO, LTD.
5
自動点呼ソリューション
点呼を『簡単』『正確』『スピーディ』に!
添乗員が車内を往復し、数取器で人数を数える。
・ 2往復する(数え間違え防止のため)。
・ 点呼に5分程度かかる。
・ 人数しか分からない…
添乗員がiPadを持って車内を往復するだけ。
・ 基本的に1往復で30秒。
・ 不在者が一目で分かる。
・ SMSや自動音声で不在者へ一斉通知が可能!
カチ!カチ!
今まで 「みんなのてんこ」導入
• 遠距離バス・観光バス
• 外国人向けツアー
• 修学旅行(観光名所めぐり)
• 工場施設や観光名所での集合点呼
活用シーン
• 企業内ミーティング、企業研修 • 国際会議、展示会
バス以外にも
!!
All Rights Reserved. Copyright © CRESCO, LTD.
6
「みんなのてんこ」のしくみ
サーバー
情報照会/連絡指示
ツアー参加者情報取得
音声通知
SMS
データ入力
ツアー参加者
添乗員
ビーコンバッジ
点呼専用
iPadアプリ
ツアー管理者
All Rights Reserved. Copyright © CRESCO, LTD.
7
ツ
ア
ー
開
始
後
ツ
ア
ー
開
始
前
ご利用の流れ
No 氏名 電話番号 言語
1 田中 太郎 090-1234-XXXX 日
2 佐藤 花子 090-YYYY-5678 日
3 ジョン スミス 080-1357-ZZZZ 英
4 張 春燕 080-XXXX-2468 中
ビーコンバッジの例
本体サイズ
直径 30mm
厚さ 10mm
お客様の用途に合わせて
・ストラップ
・リストバンド を
ご選択ください
ビーコンバッジ配布 休憩・観光(降車) 集合2 3 4
ツアー参加者に、ビーコンバッジを配布 ツ ア ー 参 加 者 に ビ ー コ ン バ ッ ジ を
身 に つ け て 、 行 動 し て も ら う
集 合 時 刻 に ア プ リ で 点 呼 開 始
点呼 不在者への連絡 ビーコンバッジ回収5 6 7
添乗員がiPadを持ってバスの通路を
往 復 す る と 、 不 在 者 が 確 認 で き る
アプリの「連絡」ボタン一つで、ツアー
参加 者の携帯電話 に SMS または自 動
音声通知で連絡できる(多国語対応)
ツ ア ー 終 了 時 に 、 ツ ア ー 参 加 者 か ら
ビ ー コ ン バ ッ ジ を 回 収
出 発 ま で に 、 ツ ア ー 参 加 者 の 情 報 を
サ ー バ ー に 登 録
ツアー参加者情報登録1
All Rights Reserved. Copyright © CRESCO, LTD.
8
★祝★てんこちゃんがTVデビュー!
All Rights Reserved. Copyright © CRESCO, LTD.
9
3つの特徴
・外国人が多いツアーでも、母国語(自動音声)による電話連絡が可能です
【簡単】車内を往復するだけなので、30秒程度で点呼が完了します
【正確】数えないので、ミスがありません
【迅速】不在者の名前が一目でわかります(一覧表示)
点呼を簡単・正確・迅速に
不在者に自動連絡(SMS/自動音声通知)
多言語対応(日,英,中 など16カ国語)
「まもなくツアーバスの出発時間となります。お集りください。」
「你很快就会成为观光巴士的起始时间 请聚会仔细」
・アイコンをタップするだけで、不在者を呼び出せます(SMS/自動音声通知)
・不在者が多い場合は、全員に一斉呼び出しすることも可能です。
・集合時間の〇分前に「まもなく集合時間です」を通知することもできます。
All Rights Reserved. Copyright © CRESCO, LTD.
10
SMSメッセージ
日本語、英語、中国語を含む
16ヶ国語に対応
All Rights Reserved. Copyright © CRESCO, LTD.
11
システム構成(概要)
ツアー当日
ツアー前日
サーバー 音声通知SMS
点呼アプリ
(iOS)
HTTP
(SSL)
旅客の
個人携帯
ユーザー
情報
管理Web
Xamarin.Forms
All Rights Reserved. Copyright © CRESCO, LTD.
12
画面イメージ
50
45
「まもなく」ボタン
まもなくツアーバスの
出発時間です。
お気をつけて
お集りください。
5 名の不在者
在席者
/
参加者
自動音声電話
SMS
iPadを持ってバス車内の通路を往復すると、アプリ
が自動的にツアー客のビーコンバッジを検知します。
「集合時間!」ボタン
バスの出発時間と
なりました。
ツアーバスに
お集りください。
①アイコンをタップして
起動します。
②ツアーを選択します。
③点呼が実行されます。
④不在者を確認し、必要に応じて連絡します。
(※一人ひとりの言語で連絡します)
DEMO
システム概要
All Rights Reserved. Copyright © CRESCO, LTD.
15
開発環境
 Windows 8.1
• Visual Studio Premium 2013 update4
• Xamarin 3.9
• Xamarin.iOS 8.6
 Mac OS X Yosemite
• Xcode 6.2
• Xamarin Studio 5.7.2
• Xamarin.iOS 8.6
• Xamarin.iOS Build Host 3.9
All Rights Reserved. Copyright © CRESCO, LTD.
16
Framework and Library
 Xamarin.Forms PCL(共通部分)
• Xamarin.Forms Styles
• Xamarin.Forms Behaviors
• Xamarin.Forms Dependency Service
• JSON.NET
• SQLite.NET
• BouncyCastle-PCL(Blowfish暗号化ライブラリ)
• Microsoft Fakes Framework (Unit Test用)
 Xamarin.iOS (プラットフォーム固有部分)
• Core Location API
• BTProgressHUD(インジケータ)
All Rights Reserved. Copyright © CRESCO, LTD.
17
みんなのてんこiOSアプリの特徴
全8画面、全て Xamarin.Forms (XAML)製!!!
iOSのCoreLocarion frameworkをXamarin.iOSから使用
開発者はC#Exportと半人前のObjective-c経験者
PCL(Portable Class Library)共通化割合89%!!!
iOSのみ対応、軌道に乗ればAndroidも。。。(´・ω・`)
All Rights Reserved. Copyright © CRESCO, LTD.
18
全8画面、全て Xamarin.Forms (XAML)製!!!
 基本、Stack Layoutの組み合わせ
 フッダーはGrid Layout
 コードビハインドで実装
 ListViewはCustom Cell実装
 Forms標準コントロールのみ
 XF.Styles, XF.Behaviors利用
All Rights Reserved. Copyright © CRESCO, LTD.
19
全8画面、全て Xamarin.Forms (XAML)製!!!
<StackLayout
Orientation="Vertical"
Padding="40,40,40,0"
Spacing="20">
<Entry
x:Name="_TenantIdEntry"
Style="{StaticResource STYLE_ENTRY_DEFAULT}"
Text=""
HorizontalOptions="FillAndExpand"
VerticalOptions="Center"
Placeholder="メールアドレスを入力してください">
<Entry.Behaviors>
<local:EntryBehaviors_MaxLength_200/>
</Entry.Behaviors>
</Entry>
…
All Rights Reserved. Copyright © CRESCO, LTD.
20
Xamarin.Forms Styles( Xamarin.Forms 1.3 以降)
UIコントロールのテンプレート化の仕組み。
アプリ全体のグローバルなスタイルを指定、使用することも可能。
//アプリ全体のスタイルを定義
Application.Current.Resources = new ResourceDictionary();
//Entryのデフォルトスタイルを定義
var STYLE_ENTRY_DEFAULT = new Style(typeof(Entry))
{
Setters = {
new Setter{Property = Entry.TextColorProperty,Value = Const.ENTRY_DEFAULT_TEXTCOLOR},
new Setter{Property = Entry.HeightRequestProperty,Value = Const.ENTRY_DEFALUT_HEIGHTREQUEST},
new Setter{Property = Entry.KeyboardProperty,Value = Const.ENTRY_DEFAULT_KEYBOARDTYPE}
}
}
Application.Current.Resources.Add("STYLE_ENTRY_DEFAULT", STYLE_ENTRY_DEFAULT);
<Entry
Style="{StaticResource STYLE_ENTRY_DEFAULT}"
</Entry>
◆XAMLでStyleを使用する場合
◆C#でStyleを使用する場合
var entry = new Entry();
entry.Style = (Style)Application.Current.Resources["STYLE_ENTRY_DEFAULT"];
All Rights Reserved. Copyright © CRESCO, LTD.
21
全8画面、全て Xamarin.Forms (XAML)製!!!
<StackLayout
Orientation="Vertical"
Padding="40,40,40,0"
Spacing="20">
<Entry
x:Name="_TenantIdEntry"
Style="{StaticResource STYLE_ENTRY_DEFAULT}"
Text=""
HorizontalOptions="FillAndExpand"
VerticalOptions="Center"
Placeholder="メールアドレスを入力してください">
<Entry.Behaviors>
<local:EntryBehaviors_MaxLength_200/>
</Entry.Behaviors>
</Entry>
…
All Rights Reserved. Copyright © CRESCO, LTD.
22
Xamarin.Forms Behaviors( Xamarin.Forms 1.3 以降)
UIコントロールに機能追加するための仕組み。
下記は200文字以上入力できなくする振舞をEntryコントロールに追加する。
public class EntryBehaviors_MaxLength_200 : Behavior<Entry>
{
//最大文字数
private static readonly int MAX_LENGTH = 200;
protected override void OnAttachedTo(Entry entry)
{
entry.TextChanged += OnEntryTextChanged;
base.OnAttachedTo(entry);
}
protected override void OnDetachingFrom(Entry entry)
{
entry.TextChanged -= OnEntryTextChanged;
base.OnDetachingFrom(entry);
}
void OnEntryTextChanged(object sender, TextChangedEventArgs args)
{
//文字列長を取得
var length = string.IsNullOrEmpty(args.NewTextValue) ? 0 : args.NewTextValue.Length;
if (length > MAX_LENGTH)
{
//長さが200を超えていると入力できない
((Entry)sender).Text = args.OldTextValue;
}
}
}
All Rights Reserved. Copyright © CRESCO, LTD.
23
var entry = new Entry();
entry.Behaviors = { new EntryBehaviors_MaxLength_200() };
◆XAMLでBehaviorsを使用する場合
◆C#でBehaviorsを使用する場合
Xamarin.Forms Behaviors( Xamarin.Forms 1.3 以降)
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:TenkoApp.View.Behaviors;assembly=TenkoApp"
<Entry
<Entry.Behaviors>
<local:EntryBehaviors_MaxLength_200/>
</Entry.Behaviors>
</Entry>
All Rights Reserved. Copyright © CRESCO, LTD.
24
ListViewはCustom Cell実装
<ListView
x:Name="_TouristListView“
…
</ListView>
private ObservableCollection<ContactListViewListCell> _cellData;
_cellData = new ObservableCollection<ContactListViewListCell>();
//セルの指定
_TouristListView.ItemTemplate = new
DataTemplate(typeof(ContactListViewListCellTemplate));
//データソースの指定
_TouristListView.ItemsSource = _cellData;
◆ContactListViewListCell.cs
Xamarin.Forms.ViewCell クラスを継承したセルテンプレートを定義
セルのイベントはここで拾っている
◆ContactListView.xaml
ListViewコントロールを定義
◆ContactListView.xaml.cs
ObservableCollectionを作成し、データバインドする
データの更新はここで行っている
All Rights Reserved. Copyright © CRESCO, LTD.
25
Xamarin.Forms Dependency Service
PCLからプラットフォーム固有の機能にアクセスする仕組み
PCL側に共通インターフェースを、プラットフォーム側に実装クラスを用意する
//PCL側に定義する共通インターフェース
public interface IBeaconManager
{
bool StartMonitoring(BeaconObject beaconInfo);
void StopMonitoring();
Action<object,BeaconEventArgs> Received { get; set; }
}
//プラットフォーム側に定義する実装クラス
[assembly: Dependency(typeof(BeaconManager_iOS))]
namespace TenkoApp.iOS
{
[Preserve(AllMembers = true)]
public class BeaconManager_iOS : IBeaconManager
{
public Action<object,BeaconEventArgs> Received { get; set; }
…
public BeaconManager_iOS(){…}
public bool StartMonitoring(BeaconObject beaconInfo){…}
public void StopMonitoring(){…}
IBeaconManagerの
iOS用実装クラスだと宣言
IBeaconManager
インターフェースを実装
All Rights Reserved. Copyright © CRESCO, LTD.
26
Xamarin.Forms Dependency Service
PCLでDependencyService呼び出し
//modelクラス
public class BeaconService
{
public BeaconObject beaconInfo { get; set; }
public IBeaconManager _beaconManager { get; set; }
//コンストラクタでDependencyService.Getでインスタンス取得
public BeaconService()
{
this._beaconManager = DependencyService.Get<IBeaconManager>();
}
public bool StartMonitoring()
{
return this._beaconManager.StartMonitoring(beaconInfo);
}
//singleton + factory class
public class BeaconServiceFactory
{
private static BeaconService beaconService { get; set; }
public static BeaconService getInstance()
{
if (beaconService == null) { beaconService = new BeaconService(); }
return beaconService;
}
}
//利用シーン(実際はbeaconInfoの初期設定は別途必要だがここでは省略)
BeaconServiceFactory.getInstance().StartMonitoring();
All Rights Reserved. Copyright © CRESCO, LTD.
27
Tips:[Preserve(AllMembers = true)]
コンパイラに対して、必要な機能ですよーとお知らせするおまじない
これがないと、Reflectionや、Dependency Service経由で使用しているクラスは、
参照がないと判断され、コンパイル対象から除外されてしまうことがある。
//PCL側に定義する共通インターフェース
public interface IBeaconManager
{
bool StartMonitoring(BeaconObject beaconInfo);
void StopMonitoring();
Action<object,BeaconEventArgs> Received { get; set; }
}
//プラットフォーム側に定義する実装クラス
[assembly: Dependency(typeof(BeaconManager_iOS))]
namespace TenkoApp.iOS
{
[Preserve(AllMembers = true)]
public class BeaconManager_iOS : IBeaconManager
{
public Action<object,BeaconEventArgs> Received { get; set; }
…
public BeaconManager_iOS(){…}
public bool StartMonitoring(BeaconObject beaconInfo){…}
public void StopMonitoring(){…}
どうかコンパイルしてくださ
いお願いします・・・
All Rights Reserved. Copyright © CRESCO, LTD.
28
iOSのCoreLocarion frameworkをXamarin.iOSから使用
基本、iOSのCoreLocation Frameworkの薄いラッパーなので、
C#流儀だけ覚えれば、感覚的に実装できる。
iOS技術者は参入しやすい。はず( ..)φメモメモ
//CLLocationManagerのインスタンス作成
CLLocationManager _CLM = [[CLLocationManager alloc] init];
◆Objective-c コード 抜粋 ◆Xamarin.iOS コード 抜粋
// 測位を開始する
[_CLM startRangingBeaconsInRegion : _CLBeaconRegion];
//デリゲートの設定
_CLM.delegate = self;
// 位置情報測位の許可を求めるメッセージを表示する
[_CLM requestAlwaysAuthorization];
//CLLocationManagerのインスタンス作成
CLLocationManager _CLM = new CLLocationManager();
// 測位を開始する
_CLM.StartRangingBeacons(_CLBeaconRegion);
//デリゲートの設定
_CLM.AuthorizationChanged += _CLM_AuthorizationChanged;
// 位置情報測位の許可を求めるメッセージを表示する
_CLM.RequestAlwaysAuthorization();
じゃぁC#erは・・・?(・ω・)ノ
All Rights Reserved. Copyright © CRESCO, LTD.
29
iOSのCoreLocarion frameworkをXamarin.iOSから使用
リファレンスが結構わかりやすいから頑張れそう(*^▽^*)無責任 笑
http://developer.xamarin.com/api/type/CoreLocation.CLLocationManager/
All Rights Reserved. Copyright © CRESCO, LTD.
30
開発者はC#Exportと半人前のObjective-c経験者
C#エキスパートいわく。
API部分、DBやmodelなどビジネスロジックを担当。PCL
暗号化のところ、PCL対応のライブラリが最初見つからなくて、焦ったそう。
ビジネスロジックをPCLで作ったが、そんなに違和感ない(´◉◞౪◟◉)
Objective-C経験者(C#スタンダード)いわく。
View周り、DependencyService、Beaconなどを担当。PCL+Xamarin.iOS
画面をXAMLで作ったが、デザイナ/Viewerがないから、デザインの確認するのに、
毎回ビルドして、微妙に違ったら修正して、またビルドして。。。 orz
イメージボタンの扱いにはまった。
今回のような画面なら、標準コントロールで十分実装可能。
iOSのプロジェクト設定とか、ビルド設定、スプラッシュ設定などは
iOSでリリース作業やったことある人なら、そんなに違和感なく設定可能な感じ。
All Rights Reserved. Copyright © CRESCO, LTD.
31
PCL(Portable Class Library)共通化割合89%!!!
分類 Step数 比率
Xamarin.Forms(PCL) 4.8KS 89%
Xamarin.iOS 0.6KS 11%
計 5.4KS 100%
もしAndroidを作ったとしても・・・
分類 Step数 比率
Xamarin.Forms(PCL) 4.8KS 80%
Xamarin.iOS 0.6KS 10%
Xamarin.Android 0.6KS 10%
計 6.0KS 100%
きっと80%は共通化できてるはず!
Xamarin万歳(^O^)/
ご清聴ありがとうございました<m(_ _)m>

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Xamarin.Formsでみんなでてんこ!

  • 1. Xamarin.Formsで みんなでてんこ! 2015年10月3日 吉田 将明 第6回 Japan Xamarin User Group Conference @東京 先端技術事業部
  • 2. All Rights Reserved. Copyright © CRESCO, LTD. 1 目次 自己紹介 みんなのてんこ 事例紹介 ソリューション概要 システム概要 開発環境、Framework 本アプリの特徴 Xamarin.Forms Beacon部分とか やってみての感想 簡単 正確 スピーディー
  • 3. All Rights Reserved. Copyright © CRESCO, LTD. 2 自己紹介 吉田 将明(よしだ まさあき) アプリケーションエンジニア 最近触ってる言語 C#,VB.NET,Objective-c,Node.js etc 兵庫県加古川育ち、東京でてきて3年目 SE→広告代理店営業→出戻りSE
  • 4. All Rights Reserved. Copyright © CRESCO, LTD. 3 はじめに。。。 田淵さん、 XLSOFTさんHPへの事例掲載、 有難う御座います(´◉◞౪◟◉)ペコリ
  • 6. All Rights Reserved. Copyright © CRESCO, LTD. 5 自動点呼ソリューション 点呼を『簡単』『正確』『スピーディ』に! 添乗員が車内を往復し、数取器で人数を数える。 ・ 2往復する(数え間違え防止のため)。 ・ 点呼に5分程度かかる。 ・ 人数しか分からない… 添乗員がiPadを持って車内を往復するだけ。 ・ 基本的に1往復で30秒。 ・ 不在者が一目で分かる。 ・ SMSや自動音声で不在者へ一斉通知が可能! カチ!カチ! 今まで 「みんなのてんこ」導入 • 遠距離バス・観光バス • 外国人向けツアー • 修学旅行(観光名所めぐり) • 工場施設や観光名所での集合点呼 活用シーン • 企業内ミーティング、企業研修 • 国際会議、展示会 バス以外にも !!
  • 7. All Rights Reserved. Copyright © CRESCO, LTD. 6 「みんなのてんこ」のしくみ サーバー 情報照会/連絡指示 ツアー参加者情報取得 音声通知 SMS データ入力 ツアー参加者 添乗員 ビーコンバッジ 点呼専用 iPadアプリ ツアー管理者
  • 8. All Rights Reserved. Copyright © CRESCO, LTD. 7 ツ ア ー 開 始 後 ツ ア ー 開 始 前 ご利用の流れ No 氏名 電話番号 言語 1 田中 太郎 090-1234-XXXX 日 2 佐藤 花子 090-YYYY-5678 日 3 ジョン スミス 080-1357-ZZZZ 英 4 張 春燕 080-XXXX-2468 中 ビーコンバッジの例 本体サイズ 直径 30mm 厚さ 10mm お客様の用途に合わせて ・ストラップ ・リストバンド を ご選択ください ビーコンバッジ配布 休憩・観光(降車) 集合2 3 4 ツアー参加者に、ビーコンバッジを配布 ツ ア ー 参 加 者 に ビ ー コ ン バ ッ ジ を 身 に つ け て 、 行 動 し て も ら う 集 合 時 刻 に ア プ リ で 点 呼 開 始 点呼 不在者への連絡 ビーコンバッジ回収5 6 7 添乗員がiPadを持ってバスの通路を 往 復 す る と 、 不 在 者 が 確 認 で き る アプリの「連絡」ボタン一つで、ツアー 参加 者の携帯電話 に SMS または自 動 音声通知で連絡できる(多国語対応) ツ ア ー 終 了 時 に 、 ツ ア ー 参 加 者 か ら ビ ー コ ン バ ッ ジ を 回 収 出 発 ま で に 、 ツ ア ー 参 加 者 の 情 報 を サ ー バ ー に 登 録 ツアー参加者情報登録1
  • 9. All Rights Reserved. Copyright © CRESCO, LTD. 8 ★祝★てんこちゃんがTVデビュー!
  • 10. All Rights Reserved. Copyright © CRESCO, LTD. 9 3つの特徴 ・外国人が多いツアーでも、母国語(自動音声)による電話連絡が可能です 【簡単】車内を往復するだけなので、30秒程度で点呼が完了します 【正確】数えないので、ミスがありません 【迅速】不在者の名前が一目でわかります(一覧表示) 点呼を簡単・正確・迅速に 不在者に自動連絡(SMS/自動音声通知) 多言語対応(日,英,中 など16カ国語) 「まもなくツアーバスの出発時間となります。お集りください。」 「你很快就会成为观光巴士的起始时间 请聚会仔细」 ・アイコンをタップするだけで、不在者を呼び出せます(SMS/自動音声通知) ・不在者が多い場合は、全員に一斉呼び出しすることも可能です。 ・集合時間の〇分前に「まもなく集合時間です」を通知することもできます。
  • 11. All Rights Reserved. Copyright © CRESCO, LTD. 10 SMSメッセージ 日本語、英語、中国語を含む 16ヶ国語に対応
  • 12. All Rights Reserved. Copyright © CRESCO, LTD. 11 システム構成(概要) ツアー当日 ツアー前日 サーバー 音声通知SMS 点呼アプリ (iOS) HTTP (SSL) 旅客の 個人携帯 ユーザー 情報 管理Web Xamarin.Forms
  • 13. All Rights Reserved. Copyright © CRESCO, LTD. 12 画面イメージ 50 45 「まもなく」ボタン まもなくツアーバスの 出発時間です。 お気をつけて お集りください。 5 名の不在者 在席者 / 参加者 自動音声電話 SMS iPadを持ってバス車内の通路を往復すると、アプリ が自動的にツアー客のビーコンバッジを検知します。 「集合時間!」ボタン バスの出発時間と なりました。 ツアーバスに お集りください。 ①アイコンをタップして 起動します。 ②ツアーを選択します。 ③点呼が実行されます。 ④不在者を確認し、必要に応じて連絡します。 (※一人ひとりの言語で連絡します)
  • 14. DEMO
  • 16. All Rights Reserved. Copyright © CRESCO, LTD. 15 開発環境  Windows 8.1 • Visual Studio Premium 2013 update4 • Xamarin 3.9 • Xamarin.iOS 8.6  Mac OS X Yosemite • Xcode 6.2 • Xamarin Studio 5.7.2 • Xamarin.iOS 8.6 • Xamarin.iOS Build Host 3.9
  • 17. All Rights Reserved. Copyright © CRESCO, LTD. 16 Framework and Library  Xamarin.Forms PCL(共通部分) • Xamarin.Forms Styles • Xamarin.Forms Behaviors • Xamarin.Forms Dependency Service • JSON.NET • SQLite.NET • BouncyCastle-PCL(Blowfish暗号化ライブラリ) • Microsoft Fakes Framework (Unit Test用)  Xamarin.iOS (プラットフォーム固有部分) • Core Location API • BTProgressHUD(インジケータ)
  • 18. All Rights Reserved. Copyright © CRESCO, LTD. 17 みんなのてんこiOSアプリの特徴 全8画面、全て Xamarin.Forms (XAML)製!!! iOSのCoreLocarion frameworkをXamarin.iOSから使用 開発者はC#Exportと半人前のObjective-c経験者 PCL(Portable Class Library)共通化割合89%!!! iOSのみ対応、軌道に乗ればAndroidも。。。(´・ω・`)
  • 19. All Rights Reserved. Copyright © CRESCO, LTD. 18 全8画面、全て Xamarin.Forms (XAML)製!!!  基本、Stack Layoutの組み合わせ  フッダーはGrid Layout  コードビハインドで実装  ListViewはCustom Cell実装  Forms標準コントロールのみ  XF.Styles, XF.Behaviors利用
  • 20. All Rights Reserved. Copyright © CRESCO, LTD. 19 全8画面、全て Xamarin.Forms (XAML)製!!! <StackLayout Orientation="Vertical" Padding="40,40,40,0" Spacing="20"> <Entry x:Name="_TenantIdEntry" Style="{StaticResource STYLE_ENTRY_DEFAULT}" Text="" HorizontalOptions="FillAndExpand" VerticalOptions="Center" Placeholder="メールアドレスを入力してください"> <Entry.Behaviors> <local:EntryBehaviors_MaxLength_200/> </Entry.Behaviors> </Entry> …
  • 21. All Rights Reserved. Copyright © CRESCO, LTD. 20 Xamarin.Forms Styles( Xamarin.Forms 1.3 以降) UIコントロールのテンプレート化の仕組み。 アプリ全体のグローバルなスタイルを指定、使用することも可能。 //アプリ全体のスタイルを定義 Application.Current.Resources = new ResourceDictionary(); //Entryのデフォルトスタイルを定義 var STYLE_ENTRY_DEFAULT = new Style(typeof(Entry)) { Setters = { new Setter{Property = Entry.TextColorProperty,Value = Const.ENTRY_DEFAULT_TEXTCOLOR}, new Setter{Property = Entry.HeightRequestProperty,Value = Const.ENTRY_DEFALUT_HEIGHTREQUEST}, new Setter{Property = Entry.KeyboardProperty,Value = Const.ENTRY_DEFAULT_KEYBOARDTYPE} } } Application.Current.Resources.Add("STYLE_ENTRY_DEFAULT", STYLE_ENTRY_DEFAULT); <Entry Style="{StaticResource STYLE_ENTRY_DEFAULT}" </Entry> ◆XAMLでStyleを使用する場合 ◆C#でStyleを使用する場合 var entry = new Entry(); entry.Style = (Style)Application.Current.Resources["STYLE_ENTRY_DEFAULT"];
  • 22. All Rights Reserved. Copyright © CRESCO, LTD. 21 全8画面、全て Xamarin.Forms (XAML)製!!! <StackLayout Orientation="Vertical" Padding="40,40,40,0" Spacing="20"> <Entry x:Name="_TenantIdEntry" Style="{StaticResource STYLE_ENTRY_DEFAULT}" Text="" HorizontalOptions="FillAndExpand" VerticalOptions="Center" Placeholder="メールアドレスを入力してください"> <Entry.Behaviors> <local:EntryBehaviors_MaxLength_200/> </Entry.Behaviors> </Entry> …
  • 23. All Rights Reserved. Copyright © CRESCO, LTD. 22 Xamarin.Forms Behaviors( Xamarin.Forms 1.3 以降) UIコントロールに機能追加するための仕組み。 下記は200文字以上入力できなくする振舞をEntryコントロールに追加する。 public class EntryBehaviors_MaxLength_200 : Behavior<Entry> { //最大文字数 private static readonly int MAX_LENGTH = 200; protected override void OnAttachedTo(Entry entry) { entry.TextChanged += OnEntryTextChanged; base.OnAttachedTo(entry); } protected override void OnDetachingFrom(Entry entry) { entry.TextChanged -= OnEntryTextChanged; base.OnDetachingFrom(entry); } void OnEntryTextChanged(object sender, TextChangedEventArgs args) { //文字列長を取得 var length = string.IsNullOrEmpty(args.NewTextValue) ? 0 : args.NewTextValue.Length; if (length > MAX_LENGTH) { //長さが200を超えていると入力できない ((Entry)sender).Text = args.OldTextValue; } } }
  • 24. All Rights Reserved. Copyright © CRESCO, LTD. 23 var entry = new Entry(); entry.Behaviors = { new EntryBehaviors_MaxLength_200() }; ◆XAMLでBehaviorsを使用する場合 ◆C#でBehaviorsを使用する場合 Xamarin.Forms Behaviors( Xamarin.Forms 1.3 以降) <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:TenkoApp.View.Behaviors;assembly=TenkoApp" <Entry <Entry.Behaviors> <local:EntryBehaviors_MaxLength_200/> </Entry.Behaviors> </Entry>
  • 25. All Rights Reserved. Copyright © CRESCO, LTD. 24 ListViewはCustom Cell実装 <ListView x:Name="_TouristListView“ … </ListView> private ObservableCollection<ContactListViewListCell> _cellData; _cellData = new ObservableCollection<ContactListViewListCell>(); //セルの指定 _TouristListView.ItemTemplate = new DataTemplate(typeof(ContactListViewListCellTemplate)); //データソースの指定 _TouristListView.ItemsSource = _cellData; ◆ContactListViewListCell.cs Xamarin.Forms.ViewCell クラスを継承したセルテンプレートを定義 セルのイベントはここで拾っている ◆ContactListView.xaml ListViewコントロールを定義 ◆ContactListView.xaml.cs ObservableCollectionを作成し、データバインドする データの更新はここで行っている
  • 26. All Rights Reserved. Copyright © CRESCO, LTD. 25 Xamarin.Forms Dependency Service PCLからプラットフォーム固有の機能にアクセスする仕組み PCL側に共通インターフェースを、プラットフォーム側に実装クラスを用意する //PCL側に定義する共通インターフェース public interface IBeaconManager { bool StartMonitoring(BeaconObject beaconInfo); void StopMonitoring(); Action<object,BeaconEventArgs> Received { get; set; } } //プラットフォーム側に定義する実装クラス [assembly: Dependency(typeof(BeaconManager_iOS))] namespace TenkoApp.iOS { [Preserve(AllMembers = true)] public class BeaconManager_iOS : IBeaconManager { public Action<object,BeaconEventArgs> Received { get; set; } … public BeaconManager_iOS(){…} public bool StartMonitoring(BeaconObject beaconInfo){…} public void StopMonitoring(){…} IBeaconManagerの iOS用実装クラスだと宣言 IBeaconManager インターフェースを実装
  • 27. All Rights Reserved. Copyright © CRESCO, LTD. 26 Xamarin.Forms Dependency Service PCLでDependencyService呼び出し //modelクラス public class BeaconService { public BeaconObject beaconInfo { get; set; } public IBeaconManager _beaconManager { get; set; } //コンストラクタでDependencyService.Getでインスタンス取得 public BeaconService() { this._beaconManager = DependencyService.Get<IBeaconManager>(); } public bool StartMonitoring() { return this._beaconManager.StartMonitoring(beaconInfo); } //singleton + factory class public class BeaconServiceFactory { private static BeaconService beaconService { get; set; } public static BeaconService getInstance() { if (beaconService == null) { beaconService = new BeaconService(); } return beaconService; } } //利用シーン(実際はbeaconInfoの初期設定は別途必要だがここでは省略) BeaconServiceFactory.getInstance().StartMonitoring();
  • 28. All Rights Reserved. Copyright © CRESCO, LTD. 27 Tips:[Preserve(AllMembers = true)] コンパイラに対して、必要な機能ですよーとお知らせするおまじない これがないと、Reflectionや、Dependency Service経由で使用しているクラスは、 参照がないと判断され、コンパイル対象から除外されてしまうことがある。 //PCL側に定義する共通インターフェース public interface IBeaconManager { bool StartMonitoring(BeaconObject beaconInfo); void StopMonitoring(); Action<object,BeaconEventArgs> Received { get; set; } } //プラットフォーム側に定義する実装クラス [assembly: Dependency(typeof(BeaconManager_iOS))] namespace TenkoApp.iOS { [Preserve(AllMembers = true)] public class BeaconManager_iOS : IBeaconManager { public Action<object,BeaconEventArgs> Received { get; set; } … public BeaconManager_iOS(){…} public bool StartMonitoring(BeaconObject beaconInfo){…} public void StopMonitoring(){…} どうかコンパイルしてくださ いお願いします・・・
  • 29. All Rights Reserved. Copyright © CRESCO, LTD. 28 iOSのCoreLocarion frameworkをXamarin.iOSから使用 基本、iOSのCoreLocation Frameworkの薄いラッパーなので、 C#流儀だけ覚えれば、感覚的に実装できる。 iOS技術者は参入しやすい。はず( ..)φメモメモ //CLLocationManagerのインスタンス作成 CLLocationManager _CLM = [[CLLocationManager alloc] init]; ◆Objective-c コード 抜粋 ◆Xamarin.iOS コード 抜粋 // 測位を開始する [_CLM startRangingBeaconsInRegion : _CLBeaconRegion]; //デリゲートの設定 _CLM.delegate = self; // 位置情報測位の許可を求めるメッセージを表示する [_CLM requestAlwaysAuthorization]; //CLLocationManagerのインスタンス作成 CLLocationManager _CLM = new CLLocationManager(); // 測位を開始する _CLM.StartRangingBeacons(_CLBeaconRegion); //デリゲートの設定 _CLM.AuthorizationChanged += _CLM_AuthorizationChanged; // 位置情報測位の許可を求めるメッセージを表示する _CLM.RequestAlwaysAuthorization(); じゃぁC#erは・・・?(・ω・)ノ
  • 30. All Rights Reserved. Copyright © CRESCO, LTD. 29 iOSのCoreLocarion frameworkをXamarin.iOSから使用 リファレンスが結構わかりやすいから頑張れそう(*^▽^*)無責任 笑 http://developer.xamarin.com/api/type/CoreLocation.CLLocationManager/
  • 31. All Rights Reserved. Copyright © CRESCO, LTD. 30 開発者はC#Exportと半人前のObjective-c経験者 C#エキスパートいわく。 API部分、DBやmodelなどビジネスロジックを担当。PCL 暗号化のところ、PCL対応のライブラリが最初見つからなくて、焦ったそう。 ビジネスロジックをPCLで作ったが、そんなに違和感ない(´◉◞౪◟◉) Objective-C経験者(C#スタンダード)いわく。 View周り、DependencyService、Beaconなどを担当。PCL+Xamarin.iOS 画面をXAMLで作ったが、デザイナ/Viewerがないから、デザインの確認するのに、 毎回ビルドして、微妙に違ったら修正して、またビルドして。。。 orz イメージボタンの扱いにはまった。 今回のような画面なら、標準コントロールで十分実装可能。 iOSのプロジェクト設定とか、ビルド設定、スプラッシュ設定などは iOSでリリース作業やったことある人なら、そんなに違和感なく設定可能な感じ。
  • 32. All Rights Reserved. Copyright © CRESCO, LTD. 31 PCL(Portable Class Library)共通化割合89%!!! 分類 Step数 比率 Xamarin.Forms(PCL) 4.8KS 89% Xamarin.iOS 0.6KS 11% 計 5.4KS 100% もしAndroidを作ったとしても・・・ 分類 Step数 比率 Xamarin.Forms(PCL) 4.8KS 80% Xamarin.iOS 0.6KS 10% Xamarin.Android 0.6KS 10% 計 6.0KS 100% きっと80%は共通化できてるはず! Xamarin万歳(^O^)/