Canvas Apps Context
When you display a canvas app inside the Salesforce app, keep these considerations in
mind.
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 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 dimensions. Since the Salesforce app is designed for mobile, the sizes we provide are different than for the full Salesforce site.
- For 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:
1//Where sr is a parsed signed request object 2var h = parseInt(sr.context.environment. 3 dimensions.clientHeight, 10); 4Sfdc.canvas.byId('divElementId').style.height = h; - The clientHeight value can be very small, particularly in a phone’s landscape mode, and users may not be able to see any content. Use min-height set to the desired height in pixels to ensure a good user experience.
- Ensure that the outermost div
elements contain the following properties: