Salesforce Mobile App Context Considerations

Keep these considerations in mind when you display a canvas app inside of the Salesforce mobile app.

When you display a canvas app inside of the feed or publisher, the canvas context you receive (either from the Signed Request or from the getContext call) contains information specific to the Salesforce mobile app publisher.

  • You can verify you’re on either the feed or publisher by looking at the displayLocation value in the environment section. For publisher, displayLocation is set to Publisher. For the feed, displayLocation is set to ChatterFeed.
  • When creating a Canvas feed item, you can specify a JSON string as the parameter’s value. When the context is sent, any value in the parameter’s field on the feed item is sent in the parameters of the environment section of the context.
  • As with any canvas app, the context contains information about the app’s dimensions. Since Salesforce is designed for mobile, the sizes we provide for it are different than the ones we provide for the full Salesforce sites.
  • To create a single-finger touch scrolling experience:
    • Ensure that the outermost div elements contain the following properties.
      • min-height: 250px;
      • overflow: scroll;
      • width: 100%;
      • -webkit-overflow-scrolling: touch;
      • -webkit-transform: translated(0%,0px,0px);
    • Set the height attribute to the clientHeight value delivered in the signed request. For example:
      // Where sr is a parsed signed request object.
      var h = parseInt(sr.context.environment.dimensions.clientHeight, 10);
      Sfdc.canvas.byId('divElementId').style.height = h;
    • The clientHeight value can be very small, particularly in a phone’s landscape mode, and users might not be able to see any content. Use min-height set to the desired height in pixels to ensure a good user experience.
    • In the navigation menu, the default puzzle icon size is 60 pixels by 60 pixels.