Salesforce

How Do I Raise a Magic Event from Native Code Running in My Mobile App? (Magic xpa 3.x)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

How Do I Raise a Magic Event from Native Code Running in My Mobile App? (Magic xpa 3.x)

You can raise a Magic xpa event from native code that will handled in your Magic xpa application. You do this by adding the following lines to your native code:

Android:

  1. Add the declaration: import com.magicsoftware.core.CoreApplication;

  2. Raise the event: CoreApplication.getInstance().invokeUserEvent(event_name,param1,param2); where event_name is the user event name and param1 and param2 are the values that will be passed to the user event handler.

iOS:

  1. Add the declaration: #import "Magicxpa.h"

  2. Add an array that will hold all of the parameters' values, ending with a nil value: NSArray *params = [NSArray arrayWithObjects:param1, param2, nil]; where param1 and param2 are the values that will be passed to the user event handler.

  3. Raise the event: [Magicxpa invokeUserEvent:event_name Params:params]; where event_name is the user event name.

Windows 10 Mobile:

Raise the event: com.magicsoftware.richclient.CoreMethodInvoker.InvokeUserEvent(event_name, param1, param2); where event_name is the user event name and param1 and param2 are the values that will be passed to the user event handler.

See also: The Rich Client Samples project (programs RNC08 and RNC09)

Asking the user to approve a permission (Android)

Sometimes, a user needs to approve specific permissions when running native code, such as for opening a device’s camera or for creating calendar entries.

You can ask the user to give approval by adding the following line to the native code, as in the example below:

boolean requestResult = CoreApplication.getInstance().requestPermission(Manifest.permission.RECORD_AUDIO);

Here, the user is requested to approve the RECORD_AUDIO permission, and the result is stored in the requestResult variable.

Since version: 3.2a

See also: The Rich Client Samples project (program RNC14)

See also

Reference
Attachment 
Attachment