90
#forcedotcomjp Salesforce1 Platformモバイル開発Tips Webinar ~セキュリティ及びプッシュ通知

Salesforce1 Platformモバイル開発Tips Webinar

Embed Size (px)

DESCRIPTION

 

Citation preview

#forcedotcomjp

Salesforce1 Platformモバイル開発Tips Webinar~セキュリティ及びプッシュ通知 編 ~

#forcedotcomjp

Developer Forceをフォローください@developerforcej/ #forcedotcomjp

Developer Force Japan

+Developer Force Japan

Developer Force Japan

Developer Force Group

#forcedotcomjp#forcedotcomjp

スピーカー

今村 和彦!

SSE!@KAZU_200WR

辻 正志!

SSE!@h2z

#forcedotcomjp

Safe HarborSafe 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 July 31, 2012. 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.

#forcedotcomjp

アジェンダ▪ Salesforce1モバイルのプッシュ通知!

▪ Salesforce1モバイルのセキュリティ!

▪ Mobile SDKのプッシュ通知!

▪ Mobile SDKのセキュリティ

Salesforce1モバイルの!プッシュ通知

#forcedotcomjp

Salesforce1モバイルアプリのプッシュ通知機能

▪ Spring ’14 から、タスク(ToDo)を割り当てる事で”好きなタイミング”でPUSH通知が可能になりました!

#forcedotcomjp

Salesforce1モバイルアプリのプッシュ通知機能 -利用方法-

▪ Apex でTask を作成する、など、、

Task pushtask = new Task(OwnerId = <通知したい相手のUser Id>, WhatId = <関連させるレコードが有ればレコードのID>, Subject = <お好みで>, ReminderDateTime =<こちらもお好みで>, ・ ・ ); Insert pushtask;

#forcedotcomjp

Salesforce1モバイルアプリのプッシュ通知機能 -注意点-

▪ [設定] から [モバイル管理] > [通知] > [設定] で有効化

Salesforce1モバイルの!セキュリティ

#forcedotcomjp

Salesforce1モバイルアプリのセキュリティ機能

▪ モバイルのセキュリティの設定は”接続アプリケーション”に集約

初期状態では表示されません。 Salesforce1 アプリの初回ログイン後 or AppExchangeインストール後に表示されます。

#forcedotcomjp

#forcedotcomjp

プロファイルで会社の固定IPなどを利用してIP制限を行っている場合でも、社外のモバイルからアクセスを許可

<セッション管理>Salesforce1 モバイルアプリのリフレッシュトークンの有効期限を設定 • デフォルトではユーザ操作でログアウトしない限りは有効

• アクセス時にログインが必要 • n時間(月・日)アクセスが無かった場合にログインを強制

• 時間(月・日)毎にログインを強制

#forcedotcomjp

PIN保護を適用

二要素認証を利用(Salesforce#)

#forcedotcomjp

Salesforce1モバイルアプリのセキュリティ機能

▪ トークンの強制失効

#forcedotcomjp

Salesforce1モバイルアプリのおまけ

▪ Spring ‘14からブランディングが可能になりました!

Mobile SDKの!プッシュ通知

#forcedotcomjp

Mobile SDK 2.1からの待望の新機能!▪ 対応デバイス!▪ Apple iOS!! Apple Push Notification Service (APNS)!▪ Google Android!! Google Cloud Messaging for Android (GCM)!

Push通知の仕組み

#forcedotcomjp

Push Notificationの仕組み (Apple)1. Push通知許可を登録!2. デバイストークン取得!3. デバイストークンを保存!4. Push通知を依頼!

5. デバイスへPush通知 APNsAppサーバ 213

4

5

#forcedotcomjp

Push Notificationの仕組み (Android GCM)1. Push通知許可を登録!

2. Registration ID取得!

3. Registration IDを保存!

4. Push通知を依頼!

5. デバイスへPush通知GCM2

13

4

5Appサーバ

#forcedotcomjp

Push Notificationの仕組み (Mobile SDK)1. Push通知許可を登録!

2. Device Token / Registration ID取得!

3. Device Token / Registration IDを保存!

4. Push通知を依頼!

5. デバイスへPush通知

APNs/ GCM

213

4

5Appサーバ

Mobile SDK

設定方法

#forcedotcomjp

設定内容1.接続アプリケーションの作成!▪ Apple/GCM!

2. Push通知の設定前準備!

▪ Apple/GCM!3.アプリケーション!▪ Apple/GCM

接続アプリケーション

#forcedotcomjp

接続アプリケーション

#forcedotcomjp

接続アプリケーションの作成

#forcedotcomjp

プッシュメッセージングの有効化 (Apple)

#forcedotcomjp

プッシュメッセージングの有効化 (Android GCM)

Push通知の設定前準備 (Apple)

#forcedotcomjp

キーチェーンアクセスの起動

#forcedotcomjp

証明書要求のためのファイル作成

#forcedotcomjp

必要事項を入力

#forcedotcomjp

保存

#forcedotcomjp

保存

#forcedotcomjp

Apple Developer ProgramでApp IDの作成

#forcedotcomjp

アプリ名の入力

#forcedotcomjp

Bundle IDの入力

#forcedotcomjp

Push Notificationsにチェック

#forcedotcomjp

確認してSubmit

#forcedotcomjp

Done

#forcedotcomjp

App IDの作成完了

#forcedotcomjp

ではなく、Editでもう一度編集

#forcedotcomjp

証明書の作成

#forcedotcomjp

Continue

#forcedotcomjp

証明書要求のファイルを選択

#forcedotcomjp

生成された証明書をダウンロード

#forcedotcomjp

ダブルクリックして証明書をインストール

#forcedotcomjp

インストール完了

#forcedotcomjp

証明書を書き出す

#forcedotcomjp

書き出し用パスワードの入力

#forcedotcomjp

OSXにログインしているユーザのパスワードを入力

#forcedotcomjp

Provisioning Profilesの作成▪ 割愛します

#forcedotcomjp

プッシュメッセージングの有効化 (Apple)

Push通知の設定前準備 (Android)

#forcedotcomjp

Google Developer Console

#forcedotcomjp

プロジェクトの作成

#forcedotcomjp

APIs & authに移動

#forcedotcomjp

Google Cloud Messaging for Androidの有効化

#forcedotcomjp

Credentialsに移動

#forcedotcomjp

サーバキーを作成

#forcedotcomjp

Serve keyを選択

#forcedotcomjp

受け付けるネットワークを入力しCreate

#forcedotcomjp

サーバキーの作成完了

#forcedotcomjp

プッシュメッセージングの有効化 (Android GCM)

アプリケーション (Apple)

#forcedotcomjp

プロジェクトの作成forceios create \! --apptype=native \! --appname="S1MobileDevWebinar" \! --companyid=com.salesforce.sse.mtsuji \! --organization=tsuji \! --appid=【コンシューマ鍵】 \!

--callbackuri=【コールバックURL】!

--outputdir=. \!

#forcedotcomjp

Bundle IDの確認

#forcedotcomjp

Provisioning Profileの選択

#forcedotcomjp

AppDelegate.mのコメントアウトを

#forcedotcomjp

解除する

アプリケーション (Android)

#forcedotcomjp

プロジェクトの作成forcedroid create \! --apptype=native \! --appname="S1MobileDevWebinar" \! --targetdir=. \! --packagename=com.salesforce.sse.mtsuji.s1webinar \! --usesmartstore=false

#forcedotcomjp

res/values/bootconfig.xmlの修正<resources>! <string name="remoteAccessConsumerKey">【コンシューマ鍵】</string>!

<string name="oauthRedirectURI">【コールバックURL】</string>!

<string-array name="oauthScopes">! <item>api</item>! </string-array>! <string name="androidPushNotificationClientId">【Project Number】</string>!

</resources>

#forcedotcomjp

Push通知用クラスの作成package com.salesforce.sse.mtsuji.s1webinar;!

!import org.apache.cordova.api.LOG;!

import android.os.Bundle;!

import com.salesforce.androidsdk.push.PushNotificationInterface;!

!public class MyPush implements PushNotificationInterface {!

! @Override!

! public void onPushMessageReceived(Bundle message) {!

! ! // TODO Auto-generated method stub!

! }!

}!

#forcedotcomjp

XXXApp#onCreateの修正@Override!

public void onCreate() {!

! super.onCreate();!

! SalesforceSDKManager.initNative(getApplicationContext(), new KeyImpl(), MainActivity.class);!

!! /*!

! * Un-comment the line below to enable push notifications in this app.!

! * Replace 'pnInterface' with your implementation of 'PushNotificationInterface'.!

! * Add your Google package ID in 'bootonfig.xml', as the value!

! * for the key 'androidPushNotificationClientId'.!

! */!

! // SalesforceSDKManager.getInstance().setPushNotificationReceiver(pnInterface);!

}

#forcedotcomjp

XXXApp#onCreateの修正@Override!

public void onCreate() {!

! super.onCreate();!

! SalesforceSDKManager.initNative(getApplicationContext(), new KeyImpl(), MainActivity.class);!

! /*!

! * Un-comment the line below to enable push notifications in this app.!

! * Replace 'pnInterface' with your implementation of 'PushNotificationInterface'.!

! * Add your Google package ID in 'bootonfig.xml', as the value!

! * for the key 'androidPushNotificationClientId'.!

! */!

! SalesforceSDKManager.getInstance().setPushNotificationReceiver(new MyPush());!

}

Push通知を送る

#forcedotcomjp

ApexからPushを送信 (Apple/Android共通)Set<String> users = new Set<String> { // Pushするユーザ! UserInfo.getUserId()!};!Messaging.PushNotification msg =! new Messaging.PushNotification();!msg.setPayload(payload);!msg.send(【アプリケーション接続API名】, users); // 送信

#forcedotcomjp

AppleのPayloadMap<String, Object> payload = Messaging.PushNotificationPayload.apple(! 'メッセージ', // 通知メッセージ! 'default', // サウンド! 99, // バッジ! new Map<String, Object> {! // データ! }!);!

#forcedotcomjp

AndroidのPayloadMap<String, Object> payload = new Map<String, Object> {! // データ!

};!

Pushデモ

#forcedotcomjp

参考文献▪ Document!

http://sfdc.co/MobileSDKPNS!▪ Qiita: MobileSDKを使わずにSalesforceにアクセスする

iPhoneアプリを作る【プッシュ通知編】!

http://qiita.com/pomu0325/items/7dae8ba399523f3e59f1!

Mobile SDKの!セキュリティ

接続アプリケーションで出来る

PIN保護

#forcedotcomjp

PIN保護にチェック

#forcedotcomjp

PINの最低文字数も変更可能

#forcedotcomjp

まとめ▪ Salesforce1 & Mobile SDK双方とも!

▪ Push通知が可能で、セキュリティ設定も柔軟!▪ 共通化されている部分は知識を流用できる!

▪ 接続アプリケーション!▪ PIN保護!