SharinPix WebView on a Native iOS Mobile Application
A WebView (or WKWebView on iOS) is a component inside a Swift application which allows the display of a web app inside a mobile application. By running the SharinPix web app inside a WebView, your native Swift application will contain the SharinPix experience usually available on Salesforce and the web. It can be seen as the equivalent of an iframe tag in HTML.
Below is an example how to generate token:
token = sharinpix.Client.getInstance().token(
new Map<String, Object> {
'Id' => wOrder.Id,
'exp' => 0,
'path' => '/pagelayout/' + wOrder.Id,
'abilities' => new Map<String, Object> {
wOrder.Id => new Map<String, Object> {
'Access' => new Map<String, Boolean> {
'see' => true,
'image_list' => true,
'image_upload' => true,
'image_delete' => true
}
},
'Display' => new Map<String, Object> {
'tags'=> true
}
}
}
);
if (Trigger.isInsert) {
updatedWOrders.add(new WorkOrder(
Id = wOrder.Id,
SharinPix_Token__c = token
));
} else {
wOrder.SharinPix_Token__c = token;
}Example of a WebView with the link
ContentController
Example of a ContentController
Example of a WebViewController
The WebViewController class will allow the Swift application to get every event that is sent by the SharinPix application
iOS Permissions
Accessing the native camera
To be able to open the native camera on your Swift application, you should include the permission "Privacy - Camera Usage Description (NSCameraUsageDescription)" in Info in your XCode project.
If the permission is not allowed hence the user will not get the native camera.
Go to your XCode Project
Click on the project
Click on Info
Add a new property by clicking on the arrow up down on the permission "Privacy - Camera Usage Description" (See screenshot below).

Below is the screenshot where the Permission Privacy - Camera Usage Description is asked.

The screenshot below shows images that are uploaded on the SharinPix application.

The screenshot shows a native alert being shown on the mobile application with the event that has been triggered when deleting an image on the SharinPix application.


