Using the SnapStart module with the Mashup SDK on iOS in Pega 7.2.1
The Mashup SDK API exposes the SnapStart module, which permits direct interaction with a connected Pega 7 Platform application from a native mobile iOS app that is developed separately. After you sign in to the Pega 7 Platform instance, you can use the SnapStart module to create a case, open an existing case, open a harness, open an assignment, or run an activity. You perform these actions by using one or more HTML web views within the native iOS app.
- Prerequisites
- Obtaining the AHCSnapStartViewController object
- Adding delegate methods
- Creating a case
- Opening a case by ID
- Showing a harness
- Opening an assignment
- Running an activity
- Additional properties
Prerequisites
Before you continue, read the following information:
- Setting up the Mashup SDK for iOS app development.
- Authenticating with Mashup on iOS.
- Mashup SDK 1.0.0 AppleDocs, which describe the API.
Obtaining the AHCSnapStartViewController object
To use the Mashup SDK SnapStart module in your Objective-C code for the native iOS app, you must initialize the AHCSnapStartViewController
object, passing it the authentication URL as a string that points to the Pega 7 Platform instance. You obtain this value when you sign in to the Pega 7 Platform instance, using the Mashup SDK Authentication module. See Authenticating with Mashup SDK on iOS.
To create multiple Mashup views, you must create separate instances of the AHCSnapStartViewController
object. Each ViewController
uses a separate instance of the HybidWebView
object internally. Assign a unique name to each webView
by using a call similar to: snapStartController.webViewName = @"caseWebView"
. You do not need to create a WebView
instance manually. Everything is handled by the AHCSnapStartViewController
object, which is a fully functional ViewController
that can be added directly to view the hierarchy.
After you obtain an instance of this object, you use it in your Objective-C code to create a case, open an existing case, show a harness, open an assignment, or run an activity by calling a specific SnapStart module function.
The following example shows how to obtain an instance of the AHCSnapStartViewController
object in Objective-C, assuming that the URL to the authenticated Pega 7 Platform instance has been previously obtained by using the Authentication module and saved in the authURL
variable:
AHCSnapStartViewController *snapStartController = [[AHCSnapStartViewController alloc] init]; snapStartController.delegate = self; snapStartController.portalURL = authURL; snapStartController.webViewName = @"caseWebView";
Adding delegate methods
When you use the SnapStart module, make sure to also add delegate methods that take into account the following user actions:
- Submitting or canceling an action, such as when a user closes the current window in the web view. The user should be taken back to the last native app screen that invoked the Pega 7 Platform web view.
- Logging out from the Pega 7 Platform instance.
For the first case, make sure to register the snapStartController:handleCloseActionWithCompletionHandler:
delegate. For the second case, make sure to register the snapStartControllerHandleUserLoggedOut:
delegate. The following Objective-C code example shows how to do this:
- (void)snapStartController:(AHCSnapStartViewController *)controller handleCloseActionWithCompletionHandler:(void (^)())completionHandler { // add code to handle window close } - (void)snapStartControllerHandleUserLoggedOut:(AHCSnapStartViewController *)controller { // add code to handle logout }
<UIPickerViewDelegate>
in the interface controller where AHCSnapStartViewController
is created.Creating a case
To create a case in the connected Pega 7 Platform instance from within your native iOS app, you must first create an instance of the AHCSSCreateCaseAction
object by calling the initWithFlowType:insClass:
method, passing it several parameters, as shown in the following table. Next, you call the performAction:
method on the instance of the AHCSnapStartViewController
object, passing it the create case object as a parameter.
Parameter | Description | Type |
---|---|---|
insClass | Class name of the work type (case type). | NSString |
flowType (required) | Name of the flow to run. | NSString |
The following example shows the Objective-C code that creates a case:
AHCSSCreateCaseAction *createCase = [[AHCSSCreateCaseAction alloc] initWithFlowType:@"pyStartCase" insClass:@"Wb-WBTest-Work-TestCase"]; [snapStartController performAction:createCase];
Opening a case by ID
To open an existing case in the connected Pega 7 Platform instance from within your native iOS app, you must first create an instance of the AHCSSOpenCaseByIdAction
object by calling the initWithInsHandle:
method, passing a parameter as shown in the following table. Next, you call the performAction:
method on the instance of the AHCSnapStartViewController
object, passing it the open case object as a parameter.
Parameter | Description | Type |
---|---|---|
insHandle | The identifier of the case (pzInsKey). | NSString |
The following example shows the Objective-C code that opens an existing case:
AHCSSOpenCaseByIdAction *openCase = [[AHCSSOpenCaseByIdAction alloc] initWithInsHandle:@"WB-WBTEST-WORK T-24"]; [snapStartController performAction:openCase];
Showing a harness
To show a harness from the connected Pega 7 Platform instance within your native iOS app, you must first create an instance of the AHCSSOpenHarnessAction
object by calling the initWithPurpose:className:
method, passing it several parameters, as shown in the following table. Next, you call the performAction:
method on the instance of the AHCSnapStartViewController
object, passing it the open harness object as a parameter.
Parameter | Description | Type |
---|---|---|
harnessTarget (required) | The destination of the harness. By default, it is always set to "newDocument", so you do not have to use it in your call. However, if needed, it can be changed to another value. | NSString |
className | The class the harness belongs to. If you use pzMobileInitActivity,then:
| NSString |
purpose (required) | The name of the harness. | NSString |
readOnly (optional) | Makes the harness read-only. Default value is false. | BOOL |
pzMobileInitActivity (optional) | Name of activity to be called to initialize data. Keep in mind that:
| NSString |
pzMobileInitActivityParams (optional) | A URL-encoded query string of parameters to go to the initialization activity. | NSString |
pzMobileContextPageName (optional) | The name of the page that the activity works that the showHarness is opened against. Keep in mind that:
| NSString |
The following is an example of Objective-C code that shows a read-only harness:
AHCSSOpenHarnessAction *openHarness = [[AHCSSOpenHarnessAction alloc] initWithPurpose:@"UserDetails" className:@"WB-WBTEST-WORK-TESTCASE"]; openHarness.readOnly = true; [snapStartController performAction:openHarness];
Opening an assignment
To open an assignment in the connected Pega 7 Platform instance from within your native iOS app, you must create an instance of the AHCSSOpenAssignmentAction
object by calling the initWithInsHandle:insClass:
method, passing it several parameters as shown in the following table. Next, you call the performAction:
method on the instance of the AHCSnapStartViewController
object, passing it the open assignment object as a parameter.
Parameter | Description | Type |
---|---|---|
insHandle | The assignment instance handle (pzInsKey). | NSString |
insClass (required) | The class of the assignment. It often consists of "Assign-". | NSString |
The following is an example of Objective-C code that opens an assignment:
AHCSSOpenAssignmentAction *openAssignment = [[AHCSSOpenAssignmentAction alloc] initWithInsHandle:@"ASSIGN-WORKLIST WB-WBTEST-WORK T-17!OPEN" insClass:@"Assign-"]; [snapStartController performAction:openAssignment];
Running an activity
To run an activity in the connected Pega 7 Platform instance from within your native iOS app, you must create an instance of the AHCSSRunActivityAction
object by calling the initWithPzActivity:pzActivityParams:
method, passing it several parameters, as shown in the following table. Next, you call the performAction:
method on the instance of the AHCSnapStartViewController
object, passing it the run activity object as a parameter.
Parameter | Description | Type |
---|---|---|
pzActivity | The name of activity to run. Keep in mind that:
| NSString |
pzActivityParams (required) | A URL-encoded query string of parameters to go to the activity. | NSString |
pzPrimaryPageName (optional) | The name of the page for the activity to work on. | NSString |
The following example shows the Objective-C code that runs an activity:
AHCSSRunActivityAction *runActivity = [[AHCSSRunActivityAction alloc] initWithPzActivity:@"TestActivity" pzActivityParams:@"test=Hello Mashup Developer!"]; [snapStartController performAction:runActivity];
Additional properties
When calling one of the SnapStart module functions (described in the sections above), on the AHCSnapStartViewController
object, for example, to create a case or open an assignment, you can also set additional optional properties, as described in the following table.
Property | Description | Type |
---|---|---|
pyShowFullPortal | If set to '1', the target content is loaded with the surrounding portal navigation. If set to '0', the target content is not loaded with the surrounding portal navigation. | NSNumber |
pyPhoneNavRuleMainVisible (optional) | If set to '1', the main navigation is visible on a phone device. If set to '0', it is not visible on a phone device. | NSNumber |
pyTabletNavRuleMainVisible (optional) | If set to '1', the main navigation is visible on a tablet device. If set to '0', it is not visible on a tablet device. | NSNumber |
pyPhoneNavRuleToolbarVisible (optional) | If set to '1', the toolbar is visible on a phone device. If set to '0', it is not visible on a phone device. | NSNumber |
pyTabletNavRuleToolbarVisible (optional) | If set to '1', the toolbar is visible on a tablet device. If set to '0', it is not visible on a tablet device. | NSNumber |
The following example shows the Objective-C code that sets several properties for the run activity object:
runActivity.pyShowFullPortal = [NSNumber numberWithBool:YES]; runActivity.pyPhoneNavRuleMainVisible = [NSNumber numberWithBool:YES]; runActivity.pyTabletNavRuleToolbarVisible = [NSNumber numberWithBool:NO]; [snapStartController performAction:runActivity];