Your SlideShare is downloading. ×
0
Beyond the Force.com Toolkit for iOS<br />Developers Track<br />Matthew Botos, Mavens Consulting <br />@BotosCloud<br />We...
Safe Harbor<br />Safe harbor statement under the Private Securities Litigation Reform Act of 1995:<br />This presentation ...
We’re Going to Build an iPad App<br />View list of Cases with details<br />Record, upload, & play audio Attachment<br />Pu...
We’re Going Beyond This…<br />
And we’re going #OpenSource!<br />github.com/mbotos/CaseMemo<br />
Step 0: Create a Free Dev Org<br />
Setup > Develop > Remote Access<br />
Skip Steps<br />Step 1: Login with Oauth<br />Step 2: Get list of Cases<br />
Step 1: Login with OAuth<br />
Step 2: Let’s Get Some Data!<br />
Step 3: Cache the OAuth Token<br />
Where should we store it?<br />NSDefaults<br />Keychain<br />CoreData<br />
Keychain<br />Cryptographically-secure storage<br />
Skip Steps<br />Step 4: Show Case details<br />Step 5: Get list of Attachments<br />Step 6: Add loading indicators<br />
Step 4:Add Some Details<br />
Step 5:Add Attachments<br />
Step 6:Add Loading Indicators<br />
Case<br />Attachment_Count__c<br />Attachment<br />ParentId<br />Trigger<br />
Step 7: Recording<br />
Step 8: Save Attachment<br />
Step 9: Play Audio<br />
Upcoming SlideShare
Loading in...5
×

Beyond the Force.com Toolkit for iOS - Dreamforce 2011

1,586

Published on

You’ve downloaded the Force.com Toolkit for iOS and built your first app, now take it to the next level by adding media attachments from your device and real-time push notifications! Join Mavens Consulting for a code-intensive walk through of the open source Salesforce Case Memo app. You’ll learn how to record audio and upload it as an Attachment to a Case in a background thread. Next, integrate real-time push notifications with Apex trigger callouts to Urban Airship’s REST API. Finally, see how these techniques are used to meet real business requirements in 2nd Opinion, a bespoke Salesforce iPhone app for doctors to manage their relationships with pharmaceutical companies.

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,586
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Download the code: http://github.com/mbotos/CaseMemoChatter for Session: https://dreamevent.my.salesforce.com/a093000000BtXA1 Contact Matthew Botos on Twitter: http://twitter.com/BotosCloudJoin the team at Mavens Consulting: http://mavens.force.com/careers
  • This is our safe harbor statement which if you cannot read, you can find on our website.  Now let’s see what’s possible with Salesforce + iOS…
  • Off-label usage – treat a condition not explicitly approved by the FDADoctor views drug information on iPhoneDictates a question using a voice recordingReceives a push notification when answeredhttp://mavens.force.com/platform#mobile
  • Start asking level questions:How many people have an iPhone?And an iPad?More devices than Benioff?How many people understand this next slide? …
  • Basic steps covered in presentation and code comments; don’t worry, you can build it from scratch!Will focus on advanced tips and tricks, even within the steps covered
  • Like ReidCarlberg’sForceDotCom Labs Apps, this one is open source!Apache 2.0 LicenseYou’re free to download it, learn it, and reuse it in other free or commercial appsI’ll be talking more about Open Source Wednesday afternoon 2:30-3 in the GitHub Open Source LabThis is the last link you will see on the screen; others are in the speaker notes for reference
  • This is how you can tell it’s going to be a technical presentation…http://developer.force.com
  • http://wiki.developerforce.com/index.php/Getting_Started_with_the_Force.com_Toolkit_for_iOSIf you set the callback URL to https://login.salesforce.com/services/oauth2/success, then the iOS toolkit will be able to automatically renew the session key at regular intervals to keep the user logged in. Callback URL can also be “oob” – “out of band” for mobile (?)
  • https://github.com/developerforce/Force.com-Toolkit-for-iOSIn Xcode, search for “STEP 1” – results in line order, not alphabeticaloAuthViewController and callbackNeed to create regular Salesforce user who can login from anywhere without Salesforce admin IP restrictionsMUST whitelist IP rangesProfessional Edition users need additional API license
  • RootViewControllerloadDataButton label is in DetailViewControllerSplitViewDelegateTitle of popover is in MainWindow.xibSplitViewControllerAdd where/limit to show best practice of bounding queries for performanceFieldValue uses API name
  • It’s a pain to login every time!(Especially if you’re building for non-business Customer Portal users)Let’s store our OAuth token so we don’t’ have toQUESTION: Where could we store it? How secure is that location?
  • Built-in, powerful, kind of a pain to useFortunately there are open source wrapper libraries like ObjectiveKeychain - https://github.com/AquaGeek/ObjectiveKeychainTIP: If the native library is awkward, look for an existing open source wrapperLicense of third-party libraries in folder or headerFrom Step 1:Need to create regular Salesforce user who can login from anywhere without Salesforce admin IP restrictionsMUST whitelist IP rangesFiller Questions:What not store in other places?What about storage of SF data?What if we login with user/pass?
  • Already have detailed data (it wasn’t that much to just grab it all)Detail View XIB: add labels; drag connectors to Detail View Controller header to create propertiesImplement Detail View Controller configureViewCase list is a TableView, so implement RootView Controller didSelectRowAtIndexPath
  • Display Attachments for Case in TableViewAsynchronous load to avoid delaying overall page load – metadata only since bodies may be largeTIP: Always load asynchronously and think about which data to lazy load
  • With attachments
  • Without attachments
  • Only make network call if needed – how can we do this without querying the Attachments?Display loading indicator using MBProgressHUD wrapper around ActivityIndicator: https://github.com/matej/MBProgressHUDAlso clear Case detail placeholders and display loading indicator until loadedAlso implement conditional loading of attachmentsAttachments loading indicator using custom TableView section header in DetailViewAttachmentsHeadernib
  • Add custom field to Cases with Attachment count, update with trigger on Attachment, initialize with CaseAttachmentCount.updateAllCases();(Can’t do a rollup summary since Attachment uses a generic ParentId instead of an explicit relationship)
  • Loading Cases
  • Loading Attachments
  • Attachments loaded
  • Use AudioSession to record to a temporary fileFormat settings are limited for recording; these were found to be efficient for voice memosQuestions:What about the lag (In simulator)?
  • Create ZKSObjectShow in local datastore; don’t need to wait on a Salesforce refreshInsert asynchronously in SalesforceQuestions:Other media types – photos, video?Other parent objects, including custom?
  • Audio Memo added to attachments list
  • Attachment created in Salesforce
  • Get audio body (lazy-loading) with indicatorTo get body for newly created attachments, set id from create resultStart audio playbackDeselect row when doneOnly get audio attachmentsQuestions:Where can I get that progress indicator?
  • Use case: notify when any Case I’ve recorded a memo for is closed
  • Native Apple Push Notification Service (APNS) interface is difficult to use (odd port, binary format)Use Urban Airship REST API instead – free account tierhttp://urbanairship.com/
  • For this, you will need a physical iPad device and an Apple iOS developer accountApple Summary:Create new App IDConfigure to Enable Push Notifications and generate Certificate for server to send pushesDetails:http://mobiforge.com/developing/story/programming-apple-push-notification-serviceshttp://urbanairship.com/ - Create account, app, and upload the push certificate you downloaded from AppleNote difference between Development and Production push!Also need to add Code Signing Entitlements file to Xcode.
  • App must prompt user to allow notifications (opt-in)Store device token in Salesforce with link to User so we can address it laterTrigger on Mobile Device fills in current User Id and enforces uniquenessCreate Custom Profile for Demo User and enable Read, Create permissions for Mobile Device
  • Add permissions to custom Profile
  • QUESTION: What Salesforce features might we use?
  • Why have two implementations?TIP: Use a mock implementation of external web services for testing
  • Setup:Add Remote SiteAdd Custom Settings with Urban Airship keysKey identifies the application to Urban AirshipSecret is for use in mobile appsMaster secret is for use in remote servers
  • If errors, check Urban Airship Error Console
  • Inactive device token = user deleted app or turned off notifications
  • 10 as of Summer 11
  • I was hoping this would be the new Salesforce mascot, but…Only 10 web callouts per contextBatch into a single UrbanAirship call for multiple Cases or Devices that require notificationTIP: Always design for bulk operations
  • By default, iOS will just take you to the applicationBy including custom userInfo in alert, we can indicate where we want to go, ie. specific Case IdImplement didReceiveRemoteNotification (if running)Check for notification in didFinishLaunchingWithOptions (if launching fresh from notification)STEP 10 e – jumping to case is in next methodQuestion:What’s necessary to deploy from sandbox to production?
  • How to use with another object – ie. AccountWhat does iOS toolkit give us out of box?Could you do this with HTML5? Push/audio
  • Transcript of "Beyond the Force.com Toolkit for iOS - Dreamforce 2011"

    1. 1. Beyond the Force.com Toolkit for iOS<br />Developers Track<br />Matthew Botos, Mavens Consulting <br />@BotosCloud<br />We’re Hiring!<br />Download the code! github.com/mbotos/CaseMemo<br />
    2. 2. Safe Harbor<br />Safe harbor statement under the Private Securities Litigation Reform Act of 1995:<br />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.<br />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.<br />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.<br />
    3. 3.
    4. 4. We’re Going to Build an iPad App<br />View list of Cases with details<br />Record, upload, & play audio Attachment<br />Push notification of closed Cases<br />
    5. 5. We’re Going Beyond This…<br />
    6. 6. And we’re going #OpenSource!<br />github.com/mbotos/CaseMemo<br />
    7. 7. Step 0: Create a Free Dev Org<br />
    8. 8. Setup > Develop > Remote Access<br />
    9. 9. Skip Steps<br />Step 1: Login with Oauth<br />Step 2: Get list of Cases<br />
    10. 10. Step 1: Login with OAuth<br />
    11. 11.
    12. 12.
    13. 13. Step 2: Let’s Get Some Data!<br />
    14. 14.
    15. 15. Step 3: Cache the OAuth Token<br />
    16. 16. Where should we store it?<br />NSDefaults<br />Keychain<br />CoreData<br />
    17. 17. Keychain<br />Cryptographically-secure storage<br />
    18. 18. Skip Steps<br />Step 4: Show Case details<br />Step 5: Get list of Attachments<br />Step 6: Add loading indicators<br />
    19. 19. Step 4:Add Some Details<br />
    20. 20.
    21. 21. Step 5:Add Attachments<br />
    22. 22.
    23. 23.
    24. 24. Step 6:Add Loading Indicators<br />
    25. 25. Case<br />Attachment_Count__c<br />Attachment<br />ParentId<br />Trigger<br />
    26. 26.
    27. 27.
    28. 28.
    29. 29. Step 7: Recording<br />
    30. 30.
    31. 31.
    32. 32.
    33. 33. Step 8: Save Attachment<br />
    34. 34.
    35. 35.
    36. 36. Step 9: Play Audio<br />
    37. 37.
    38. 38. Step 10: Push Notifications<br />
    39. 39. How Push Notifications Work<br />Device<br />
    40. 40. Service Setup<br />Certificates <br />Urban Airship<br />
    41. 41. Push Registration<br />
    42. 42.
    43. 43. Salesforce Notifications<br />
    44. 44. What will we use?<br />Apex Trigger<br />Apex Class<br />Web Callout<br />
    45. 45. Salesforce Push Architecture<br />Case Trigger<br />CasePushNotification<br />Push Notification Interface<br />Urban Airship Implementation<br />Mock Implementation<br />
    46. 46. Push Notification Settings<br />
    47. 47. Push Log<br />Sending to https://go.urbanairship.com/api/push/batch/: [{"aps": {"alert": "Your case has been closed”…<br />System.HttpResponse[Status=OK, StatusCode=200]<br />
    48. 48. Urban Airship Error Console<br />
    49. 49. How many web callouts per context?<br />10<br />20<br />50<br />
    50. 50. Governor Limits<br />Queue web callouts for single batch<br />
    51. 51. Receive Notifications<br />
    52. 52.
    53. 53. Beyond Where We Started<br />Open Source. OAuth. Keychain Secure Storage. Incremental Loading. Audio Recording. Audio Playback. Push Notifications.<br />
    54. 54. Thanks for goingBeyond the Force.com Toolkit for iOS!<br />Matthew Botos <br />@BotosCloud<br />We’re Hiring!<br />Download the code! github.com/mbotos/CaseMemo<br />
    55. 55. But wait, the DevZone has more!<br />Hackathon<br />Check out the Finale, Thurs, 2:30pm<br />Open Source Lab<br />Discover new & interesting open projects<br />Lightning Forum<br />Drop in for a quick blast of knowledge<br />Tech Demos<br />See and learn the latest from the experts<br />Code Consultations<br /> Sign up for 1:1 sessions at the Welcome Desk<br />@forcedotcom<br />
    56. 56. How Could Dreamforce Be Even Better? Tell Us!<br />Every session survey you submit is a chance to win an iPad 2!<br />Watch your inbox at the end of each day for an email from our survey partner, Alliance Tech.<br />Click on the personalized link to be directed to the survey page for the sessions you attended. <br />
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×