Making Your Apps More Sociable
description
Transcript of Making Your Apps More Sociable
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Making your apps more sociable
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Contents
Map & Locations features– Map control– Location provider– Remote landmark store
Social features– Buddy– SNS gateway
2
*This material is based on bada SDK 1.0.0b3
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Map in bada
3
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Think of this …
4
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
To do this, you need to …
Display a map– Map control
Get my current location– Location provider
Store information which has a location– Database– Landmark store (Device & Remote )
5
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Location application essentials
You must set the privilege group:
Features Header Library Priv. group Priv. level
Map Control
FLocations.h
FlocationControls LOCATION_SERVICE NORMAL
Location ProviderFLocations
LOCATION NORMALRemote Landmark Store REMOTE_LANDMARK SYSTEM
6
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Map in bada1. Map control
2. Location provider
3. Remote landmark store
7
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Getting a deCarta keyGO!http://developer.decarta.com
8
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Using the map control (1/4)
Step 1: Set the map key for deCarta:String extraInfo = L"ClientName=( );ClientPassword=( );HostUrl=http://ws.decarta.com/openls/openls";
9
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Using the map control (2/4)
Step 1: Set the map key for deCarta:
Step 2: Create a map provider:
String extraInfo = L"ClientName=( );ClientPassword=( );HostUrl=http://ws.decarta.com/openls/openls";
IMapServiceProvider* __pMapProvider;
__pMapProvider = static_cast<IMapServiceProvider*>(ProviderManager::ConnectToServiceProviderN(L"deCarta",LOC_SVC_PROVIDER_TYPE_MAP, extraInfo));
10
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Using the map control (3/4)
Step 1: Set the map key for deCarta
Step 2: Create a map provider
Step 3: Construct the map control:__pMap = new Map();__pMap->Construct(Rectangle(/*size*/), *__pMapProvider);
11
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Using the map control (4/4)
Step 1: Set the map key for deCarta
Step 2: Create a map provider
Step 3: Construct the map control:
Step 4: Set the map control :
__pMap = new Map();__pMap->Construct(Rectangle(/*size*/), *__pMapProvider);
__pMap->SetCenter(/* latitude, longitude */, false);__pMap->SetPanEnabled(true);
12
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
When maps are not displayed
Check that the name and password are valid
Check the proxy if you are
in a proxy environment
13
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Setting proxies
Run the simulator:
Menu > Settings > Connectivity > Network > Connection > bada
14
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Location in bada1. Map control
2. Location provider
3. Remote Landmark Store
15
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Getting the position from the GPS
Step 1: Add a location update listener:__pLocProvider = new LocationProvider();__pLocProvider->Construct(LOC_METHOD_GPS);__pLocProvider->RequestLocationUpdates
(/*ILocationListener &*/, 5, false);
16
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Getting the position from the GPS
Step 1: Add a location update listener:
Step 2: Get the position in the listener:
__pLocProvider = new LocationProvider();__pLocProvider->Construct(LOC_METHOD_GPS);__pLocProvider->RequestLocationUpdates
(/*ILocationListener &*/, 5, false);
void MyClass::OnLocationUpdated(Location &loc){
const QualifiedCoordinates* pCoord = loc.GetQualifiedCoordinates();
if (null != pCoord)__pMap->SetCenter(*pCoord, true);
}
17
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Location in bada1. Map control
2. Location provider
3. Remote landmark store
18
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Landmarks
A landmark is a location that has a name
In bada, Landmark consists of:Data structures
Name
Description
Coordinates
…
19
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Landmark stores
A landmark store is a persistent database for landmarks
Landmarks can be stored on the device or on the bada Server
Remote landmark stores can be shared among bada users
20
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Accessing bada Server
You need a bada account to store landmarks on bada Server
Samsung bada provides an easier way for sign up and sign in:– AppControl
21
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
AppControl
AppControl is used to start an application and control specific behavior in it
APPCONTROL_CALENDAR APPCONTROL_DIAL APPCONTROL_MEDIA
22
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Signing in the bada Server
AppControl* pAc = AppManager::FindAppControlN(APPCONTROL_SIGNIN, OPERATION_SIGNIN);
if(null != pAc) {pAc->Start(null, this);delete pAc;
}
23
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Adding landmarks to a LandmarkStore
Step 1: Create a landmark:Landmark* pLandmark = new Landmark();pLandmark->SetQualifiedCoordinates(/* QualfiedCoor */);pLandmark->SetName(/*name*/);pLandmark->SetDescription(/*description*/);
24
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Adding landmarks to a LandmarkStore
Step 1: Create a landmark:
Step 2: Add a landmark to a RemoteLandmarkStore:
Landmark* pLandmark = new Landmark();pLandmark->SetQualifiedCoordinates(/* QualfiedCoor */);pLandmark->SetName(/*name*/);pLandmark->SetDescription(/*description*/);
__pServerStore = new RemoteLandmarkStore(/*STORE NAME*/, /*IRemoteLandmarkStoreListener&*/);
__pServerStore->AddLandmark(*pLandmark, /*category*/, reqId);
25
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Searching for landmarks (1/2)
Step 1: Request a search:void MyApp::OnMapDrawCompleted(const Map& source){
RectangleGeographicArea area= source.GetViewport();LandmarkFilter filter;filter.SetGeographicAreaFilter(&area);
}
26
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Searching for landmarks (1/2)
Step 1: Request a search:void MyApp::OnMapDrawCompleted(const Map& source){
RectangleGeographicArea area= source.GetViewport();LandmarkFilter filter;filter.SetGeographicAreaFilter(&area);
LandmarkPropertySelector selector;selector.SetQualifiedCoordinatesSelector(true);selector.SetDescriptionSelector(true);
}
27
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Searching for landmarks (1/2)
Step 1: Request a search:void MyApp::OnMapDrawCompleted(const Map& source){
RectangleGeographicArea area= source.GetViewport();LandmarkFilter filter;filter.SetGeographicAreaFilter(&area);
LandmarkPropertySelector selector;selector.SetQualifiedCoordinatesSelector(true);selector.SetDescriptionSelector(true);
RequestId reqId;__pServerStore->SearchLandmarks
(&filter, &selector, null, SORT_ORDER_ASCENDING, SORT_BY_NAME, reqId);
}
28
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Searching for landmarks (2/2)
Step 1: Request a search
Step 2: Get results:void MyApp::OnLandmarksReceivedN(…, IList* pResults, …){
// implement this handler}
29
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Landmark Manager Demo:
30
Demo sequence:– Display a map– Search the nearby landmark– Display the landmark information
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
More features for locationsModule Major Uses
Remote locationprovider
Send a location to bada ServerGet other people’s (last known) position
Trace service Get other people’s trajectories
Map service Get a map
Directory service Search through landmarks from a service provider
Geocoding service Perform geocoding and reverse-geocoding
Route service Get a routing information from starting point to end point
31
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
When Location meets social features …
32
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Using buddy features
Request, respond to, and delete buddies
Manage groups and friendship levels within your buddies
Share your location, contents, or profile with buddies
33
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Social in bada1. Searching profile
2. Becoming buddies
3. Sharing locations
34
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Searching profile
bada Server
1. Set profile exposure level2. Search Mike’s profile
3.Send buddy request
4. Respond tobuddy request
35
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Mike: Set profile exposure level
Step 1: Create a PrivacyManager:__privacyManager = new PrivacyManager();__privacyManager->Construct
(IPrivacyManagerListener&);
I want to share my location
36
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Mike: Set profile exposure level
Step 1: Create a PrivacyManager:
Step 2: Set the ProfileExposureLevel:
__privacyManager = new PrivacyManager();__privacyManager->Construct
(IPrivacyManagerListener&);
__privacyManager->SetProfileExposureLevel(PROFILE_SEARCHABLE, reqId);
Set my profile searchable
37
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Mike: Set profile exposure level
Step 1: Create a PrivacyManager:
Step 2: Set the ProfileExposureLevel:
Step 3: Confirm the result:
__privacyManager = new PrivacyManager();__privacyManager->Construct
(IPrivacyManagerListener&);
__privacyManager->SetProfileExposureLevel(PROFILE_SEARCHABLE, reqId);
Is the set request
successful?
void OnProfileExposureLevelUpdated(){…}
You must sign-in with bada account before using PrivacyManager!38
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Jane: Search profile
Step 1: Construct a ProfileService:__pProfileService = new ProfileService();__pProfileService->Construct
(IProfileServiceListener&);
I want to find some friends
on bada
39
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Jane: Search profile
Step 1: Construct a ProfileService:
Step 2: Search profiles:
– Search by Email, LoginId, Name, PhoneNumber
__pProfileService = new ProfileService();__pProfileService->Construct
(IProfileServiceListener&);
__pProfileService->SearchProfilesByName(L”Mike”, …);
Let me try Mike
40
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Jane: Search profile
Step 1: Construct a ProfileService:
Step 2: Search profiles:
– Search by Email, LoginId, Name, PhoneNumber
Step 3: Receive profiles:
__pProfileService = new ProfileService();__pProfileService->Construct
(IProfileServiceListener&);
__pProfileService->SearchProfilesByName(L”Mike”, …);
void OnProfileSearchResultsReceivedN(…, Osp::Base::Collection::IList* pBasicProfileList,…)
{…}
Can I check the results?
41
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Social1. Searching profile
2. Becoming buddies
3. Sharing locations
42
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Becoming buddies
bada Server
1. Set profile exposure level2. Search Mike’s profile
3. Send abuddy request 4. Respond to buddy request
43
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Jane: Send a buddy request
Step 1: Create a BuddyService:__pBuddyService = new BuddyService();__pBuddyService->Construct
(IBuddyServiceListener &);
How can I send the
request to Mike
44
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Jane: Send a buddy request
Step 1: Create a BuddyService:
Step 2: Send a buddy request:
__pBuddyService = new BuddyService();__pBuddyService->Construct
(IBuddyServiceListener &);
__pBuddyService->RequestBuddy(/* Mikes’s UserID */, reqId);
Send the request
45
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Jane: Send a buddy request
Step 1: Create a BuddyService:
Step 2: Send a buddy request:
Step 3: Confirm results:
__pBuddyService = new BuddyService();__pBuddyService->Construct
(IBuddyServiceListener &);
__pBuddyService->RequestBuddy(/* Mikes’s UserID */, reqId);
And I can confirm the
results
void OnBuddyRequestSent(…){…}
46
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Mike: Respond to a buddy request
Step 1: Get buddy requests: __pBuddyService->GetReceivedBuddyRequests(reqId);
Is there any buddy
request I received?
47
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Mike: Respond to a buddy request
Step 1: Get buddy requests:
Step 2: Receive buddy requests:
__pBuddyService->GetReceivedBuddyRequests(reqId);
void OnReceivedBuddyRequestsReceivedN(…,IList*pRequestList ,…)
{…}
Get the request from the server
48
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Mike: Respond to a buddy request
Step 1: Get buddy requests:
Step 2: Receive buddy requests:
Step 3: Respond to buddy requests:
__pBuddyService->GetReceivedBuddyRequests(reqId);
void OnReceivedBuddyRequestsReceivedN(…,IList*pRequestList ,…)
{…}
__pBuddyService->RespondToBuddyRequest(*pRequest, RESPONSE_ACCEPT , reqId);
Got Jane’s, Ok accept!
49
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Social 1. Searching profile
2. Becoming buddies
3. Sharing locations
50
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Sharing locations
bada Server
1. Share Mike’s location
2. Search Mike’s location
51
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Mike: Share a location
Step 1: Set access control list for location:__privacyManager->SetUserInfoPrivacy
(INFO_LOCATION , ACCESS_BUDDY , reqId);
Can I share my location
to my friends?
52
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Mike: Share a location
Step 1: Set access control list for location:
Step 2: Get Mike’s location:
__privacyManager->SetUserInfoPrivacy(INFO_LOCATION , ACCESS_BUDDY , reqId);
__pLocationProvider->RequestLocationUpdates(…);
Get my current location
53
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Mike: Share a location
Step 1: Set access control list for location:
Step 2: Get Mike’s location:
Step 3: Register Mike’s location to bada Server:
__privacyManager->SetUserInfoPrivacy(INFO_LOCATION , ACCESS_BUDDY , reqId);
__pLocationProvider->RequestLocationUpdates(…);
RemoteLocationProvider::StartLocationReport(…);
Send my location to the server
54
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
MyPlace Demo:
55
Demo sequence:– Display a map– Get my friends location– Display them on the map
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
The SNS Gateway
56
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
SNS gateway
The SNS gateway has unified APIs for different SNS providers
Check the SNS provider’s features and properties before using the SNS gateway:
* MySpace will be supported in SDK b2
Property Description Twitter Facebook
First Name The person’s given name.
Last Name The person’s family name.
Display Name The person’s display name.
User Name The person’s user name.
57
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
SNS gateway
badaServer
1. Sharing my position
3. Set my status4. Get friend status
2. Show my and Jane’s locations
Mike Jane
SNS Server Alice
58
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Authentication
Step 1: Create SNS gateway __pSnsGateway = new SnsGateway();__pSnsGateway->Construct
(ISnsGatewayListener&, ISnsContentListener *,ISnsPeopleListener *, ISnsActivityListener *);
59
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Authentication
Step 1: Create SNS gateway
Step 2: Login to SNS account using SNS gateway API
__pSnsGateway = new SnsGateway();__pSnsGateway->Construct
(ISnsGatewayListener&, ISnsContentListener *, ISnsPeopleListener *, ISnsActivityListener *);
__pAuthenticator = new SnsAuthenticator();__pAuthenticator->Construct(ISnsAuthenticatorListener & );__pAuthenticator->Authenticate
(L"twitter", /*Key*/, /*Secret*/);…__pSnsGateway->AddAuthResult(authResult);
60
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Updating and getting status
Update user status:__pSnsGateway->UpdateMyStatusText
(L”twitter”, L”Let’s meet at Starbucks”, reqId);
61
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Updating and getting status
Update user status:
Get friend’s status :
__pSnsGateway->UpdateMyStatusText(L”twitter”, L”Let’s meet at Starbucks”, reqId);
__pSnsGateway->GetStatusText(L"twitter", L”Mike”, reqId);
…void OnSnsStatusTextReceived
(..., SnsStatusText *pStatusText, ...)
62
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
SimpleTwitter Demo:
63
Demo sequence:– Sing-in with the bada account– Authenticate with the Twitter server– Update tweets
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Manage personal data on the device and server
Share and interact with other users
More social features
Device Features
23
Server-assisted Features
•AddressBook
•CalendarBook
•Lifelog
•Buddy •Profile •Board
•Messaging •SNS Gateway
IM
64
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Social application essentials
Features Header Library Priv. Group Priv. LevelPrivacyManager
FSocial.h FSocialServices
PRIVACY_SERVICE SYSTEMProfileService PROFILE_SERVICE SYSTEMBuddyService BUDDY_SERVICE SYSTEMSnsGateway SNS_SERVICE SYSTEM
65
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Summary
66
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
What we have learned
Locations:– How to use the Map control– How to get a location– How to use a remote landmark store– How to get other people’s locations
Social:– How to get buddy– How to use the SNS Gateway
67
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Find out more: Locations
Tutorial:– bada Tutorial.Location.pdf
Samples:– LandmarkManager– LocationManager– MapControl– MapViewer– Navigator
68
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.
Find out more: Social
Tutorial:– bada Tutorial.Social.pdf
Samples:– BuddyManager– PrivacyManager– SimpleTwitter– TwitterOAuth
69
Copyright© 2010 Samsung Electronics, Co., Ltd. All rights reserved.Dive into