Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

This content has been archived and is no longer being updated.

Links may not function; however, this content may be relevant to outdated versions of the product.

Using the SnapStart module with the Mashup SDK on iOS in Pega 7.2.1

Updated on July 26, 2018

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

Before you continue, read the following information:

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 
}
Make sure to also declare <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.

ParameterDescriptionType

insClass
(required)

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.

ParameterDescriptionType

insHandle
(required)

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.

ParameterDescriptionType
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
(required)

The class the harness belongs to. If you use pzMobileInitActivity,then:

  • This is the class of that activity.
  • The class of the harness is the class of the page (pzMobileContextPageName) that is created by this activity.
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:

  • This is only the activity name.
  • The class is defined in the className parameter.
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:

  • This parameter is required if also using PzMobileInitActivity parameter in the call.
  • For example, if you want your harness to show report data, you could name your page "reportPage" and:
    • In your activity, you would create "reportPage" and fill it out with report data.
    • The harness is then displayed using "reportPage".
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.

ParameterDescriptionType

insHandle
(required)

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.

ParameterDescriptionType

pzActivity
(required)

The name of activity to run. Keep in mind that:

  • It uses the "activityName" or "className.activityName" form.
  • With no class, it is either "@baseclass" or the class of the pzPrimaryPageName.
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.

PropertyDescriptionType

pyShowFullPortal
(optional)

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];

Tags

Pega Platform 7.2.1 Pega Mobile Mashup Mobile Pega Express Consumer Services Consumer Services Manufacturing Financial Services Consumer Services Communications and Media Government Healthcare and Life Sciences Healthcare and Life Sciences Insurance

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us