Upload
salesforce-developers-japan
View
1.922
Download
7
Embed Size (px)
DESCRIPTION
「Salesforce mobile SDK Webinar」の発表資料です。 Developer Force JapanではForce.com開発者に必要な各種技術資料の公開や、Webinarセミナー等を定期的に開催しております。 http://jp.force.com/
Citation preview
Salesforce Mobile SDKISV Architect, 中嶋 一樹
1
Safe Harbor
Safe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of intellectual property and other litigation, risks associated with possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-Q for the most recent fiscal quarter ended April 30, 2011. This documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
2
3
3
ネイティブアプリ
4
iOSネイティブアプリの特徴
• リッチなユーザーインターフェース• デバイス機能の活用• App Storeでの配信• XcodeとObjective Cで開発• ホーム画面に残る
5
リソースサーバ
データベース
API
Force.comと連携するiOSネイティブアプリのアーキテクチャ
Force.com
Apex
iOS SDK
Salesforce Mobile SDK
認証サーバ
6
リソースサーバ
データベース
API
Force.comと連携するiOSネイティブアプリのアーキテクチャ
Force.com
Apex
iOS SDK
Salesforce Mobile SDK
認証サーバ
①認証・認可
6
リソースサーバ
データベース
API
Force.comと連携するiOSネイティブアプリのアーキテクチャ
Force.com
Apex
iOS SDK
Salesforce Mobile SDK
認証サーバ
①認証・認可
②アクセストークン
6
リソースサーバ
データベース
API
Force.comと連携するiOSネイティブアプリのアーキテクチャ
Force.com
Apex
iOS SDK
Salesforce Mobile SDK
認証サーバ
①認証・認可
②アクセストークン
③リクエスト
6
Demo App
7
Mobile SDKのインストールとプロジェクト作成
$ git clone https://github.com/forcedotcom/SalesforceMobileSDK-iOS.gt
githubのレポジトリをクローン(ダウンロード)
$ cd SalesforceMobileSDK-iOS/
$ ./install.sh
インストールスクリプトを実行
Xcodeのインストール
Native Force.com REST Appテンプレートからプロジェクトを作成
*Use Automatic Reference Countingのチェックをはずす
8
Mobile SDK Nativeテンプレートの構造
SFNativeRestAppDelegate
SFAuthorizingViewController
RootViewController
AppDelegate
認証後のアプリケーションのメイン画面を制御*サンプルアプリではユーザ名を10個取得し、テーブルビューに表示
Consumer IDとCallback URLを設定
認証画面を制御
UIApplicationDelegateプロトコルに従い、アプリケーション起動から認証までの挙動を担当
9
SFNativeRestAppDelegate
didFinishLauchingWithOptions:(NSDictionary *)launchOptions
setupAuthorizingViewController
rootViewControllerにSFAuthorizingViewControllerのインスタンスをセットし、アクティブに
setupAuthorizingViewControllerをキック
loggedIn
newRootViewControllerをキックしrootViewControllerにRootViewController(アプリのコントローラ)をセットし、アクティブに*newRootViewControllerはAppDelegateで実装されている
10
RootViewController
viewDidLoad
didLoadResponse:(id)jsonResponse
レスポンスをself.datarowsにセット
メニューバーのタイトルをセットForce.comからユーザー名を10個取得
cellForRowAtIndexPath:(NSIndexPath *)indexPath
テーブルのセルをデキューまたは生成し、ユーザー名をセット
SFRestRequest *request = [[SFRestAPI sharedInstance] requestForQuery:@"SELECT Name FROM User LIMIT 10"]; [[SFRestAPI sharedInstance] send:request delegate:self];
11
SFAuthCoodinatorDelegate
AppDelegate
SFNativeRestAppDelegate
SFAuthorizingViewController
RootViewController
SFRestAPI
UITableViewControllerUIViewControllerUIApplicationDelegate
SFRestRequest
UIAlertViewDelegate
Subclass
Subclass
Protocol
Subclass
Import
Import
12
NSString *objectType = @"Contact"; NSDictionary *fields = [@"{FirstName:Kazuki, LastName:Nakajima}" JSONValue];
SFRestRequest *request = [[SFRestAPI sharedInstance] requestForCreateWithObjectType:objectType fields:fields];
[[SFRestAPI sharedInstance] send:request delegate:self];
CRUD操作
NSString *objectId = @"1234567890";NSString *objectType = @"Contact"; SFRestRequest *request = [[SFRestAPI sharedInstance]
requestForDeleteWithObjectType:objectType objectId:objectId];
[[SFRestAPI sharedInstance] send:request delegate:self];
レコード作成
レコード削除
13
ハイブリッドアプリ
14
iOSハイブリッドアプリの特徴
• Web技術での開発• デバイス機能を呼び出し可能• App Storeでの配信• ホーム画面に残る
15
リソースサーバ
データベース
API
Force.comと連携するiOSハイブリッドアプリのアーキテクチャ
Force.com
Apex
iOS SDK
Salesforce Mobile SDK
認証サーバ
①認証・認可
②アクセストークン
③リクエスト
Force.com Javascript REST Toolkit
16
Demo App
17
プロジェクト作成
Hybrid Force.com Appテンプレートからプロジェクトを作成*Use Automatic Reference Countingのチェックをはずす
wwwフォルダを右クリックして一旦削除するポップアップではRemove Referencesをクリック
プロジェクトを右クリックしてshow in finderを選択し、wwwフォルダをドラッグ&ドロップでプロジェクトに追加する*Copy items into destination group’s folder (if needed)を選択*Create folder references for any added foldersを選択
wwwフォルダが青色であることを確認する
18
Mobile SDK Hybridテンプレートの構造
inline.js
index.html
forcetk.js
bootconfig.js
Force.com JavaScript REST Toolkit。RESTアクセスのラッパー
Consumer IDとCallback URL等の設定を記述
アプリケーションのメイン画面
サンプルアプリの処理
SalesforceOAuthPlugin.js
PhoneGapのAPIを利用して認証処理を実装
phonegap-x.x.x.js
PhoneGapのAPIを提供
19
bootconfig.jsdebugMode = true | false;
remoteAccessConsumerKey = xxx;
コンシューマ鍵をセット
logToConsoleメソッドの出力がスクリーンに表示されるかどうか
oauthRedirectURI = [xxx]
コールバックURLをセット
oauthScopes = ['xxx','xxx'];
発行されるトークンの権限
startData = new SFHybridApp.LocalAppStartData(); | new SFHybridApp.RemoteAppStartData("[VFページのパス]");
コンテンツがローカル管理の場合はLocalAppStartData()をセットコンテンツがVisualforce管理の場合はRemoteAppStartData()をセット
autoRefreshOnForeground = true | false;
OAuthセッションを自動リフレッシュするかどうか
20
index.html
jQuery(document).ready(function(){}
onDeviceReady(){}
SalesforceOAuthPlugin.getAuthCredentials()をキックsalesforceSessionRefreshイベント発生時にsalesforceSessionRefreshed()をキックすることを登録reLinkClickHandlers()をキック(サンプルアプリのクリックイベントを登録)
devicereadyイベント発生時にonDeviceReady()をキックすることを登録
salesforceSessionRefreshed(){}
forcetk.Clientのインスタンスを生成し、認証で得られたトークンをセット
21
PhongeGap.plist*ファイルの場所はプロジェクト名 > Supporting Files > PhoneGap.plist
ExternalHosts
JavaScriptやCSSのライブラリを外部サーバから読み込む場合はドメインを明記する必要がある
22
Force.com JavaScript REST Toolkit
レコード作成
SOQL発行
forcetkClient.query(soql, callback, error);
forcetkClient.create(objtype, fields, callback, error);
Apex Rest発行
forcetk.Client.apexrest(path, callback, error, method, payload, retry);
レコード削除forcetkClient.del(objtype, id, callback, error);
インスタンス生成var forcetkClient = new forcetk.Client(clientId, loginUrl, proxyUrl);
forcetkClient.setSessionToken(sessionId, apiVersion, instanceUrl);トークンセット
23
PhoneGapで提供される機能
各APIについて詳しくはhttp://docs.phonegap.com/en/1.6.1/index.htmlを参照
加速度センサーカメラコンパス連絡先ストレージ
位置情報プッシュ通知音楽データマイク回線
$j(document).on('tap', '#page_create_survey #button_capture_business_card', function(){ navigator.camera.getPicture(onCameraSuccess, onCameraFail, { quality: 50, destinationType: Camera.DestinationType.DATA_URL }); });
カメラ呼び出しの例
24
ありがとうございました!
25