How to Accept Parameter Files Downloaded from TMS: Difference between revisions

From wizarPOS
(Created page with "== How to configure parameter file on WizarView == Please reference to the WizarView specification. === configure template file === # Select Templates>Configuration File, then...")
 
No edit summary
Line 1: Line 1:
== How to configure parameter file on WizarView ==
== How to configure parameter file on WizarView ==
Please reference to the WizarView specification.
Please reference to the WizarView specification.
=== configure template file ===
# Select Templates>Configuration File, then click (+) icon in the left bottom of the tool box, in the popup window, write the name and other input area, choose the configuration file, click Commit button.
# Select Templates>Template, then click (+) icon in the left bottom of the tool box, in the popup window, write the name and other input area, select the configuration file create in the first step, write the package name of the app which want to accept the template parameter.
# Select Terminals>Terminal, select the serial number of the POS you want to push template parameter.
# Select Config Application parameter icon in the bottom toolbox, in the popup window, click Add button in the left bottom, select the template parameter created and modify the value in the UI, then you can push it like push an app.
=== configure normal parameter file ===
=== configure normal parameter file ===
# Add a new parameter file in WizarView, click Applications>Application, then click + icon in the left bottom of the tool box, in the popup window, write the name and other input area, then select type param, click Commit button.
# Add a new parameter file in WizarView, click Applications>Application, then click + icon in the left bottom of the tool box, in the popup window, write the name and other input area, then select type param, click Commit button.
Line 16: Line 11:
The parameter file has configured in WizarView now.
The parameter file has configured in WizarView now.
The pushing process is same with pushing an app.
The pushing process is same with pushing an app.
=== configure template file ===
# Select Templates>Configuration File, then click (+) icon in the left bottom of the tool box, in the popup window, write the name and other input area, choose the configuration file, click Commit button.
# Select Templates>Template, then click (+) icon in the left bottom of the tool box, in the popup window, write the name and other input area, select the configuration file create in the first step, write the package name of the app which want to accept the template parameter.
# Select Terminals>Terminal, select the serial number of the POS you want to push template parameter.
# Select Config Application parameter icon in the bottom toolbox, in the popup window, click Add button in the left bottom, select the template parameter created and modify the value in the UI, then you can push it like push an app.


== How to receive parameters in app ==
== How to receive parameters in app ==

Revision as of 07:52, 2 July 2019

How to configure parameter file on WizarView

Please reference to the WizarView specification.

configure normal parameter file

  1. Add a new parameter file in WizarView, click Applications>Application, then click + icon in the left bottom of the tool box, in the popup window, write the name and other input area, then select type param, click Commit button.
  2. Click Search button in the Applications>Application page.
  3. Select the parameter file name in the list.
  4. Select config icon in the right bottom of the tool box.
  5. Select Upload button in the popup window.
  6. Input the parameter file name, please notice that, the name format must be package name#parameter file name.
  7. Choose the upload file, the format of file name should be package name#parameter file name, then click Commit button.

The parameter file has configured in WizarView now. The pushing process is same with pushing an app.

configure template file

  1. Select Templates>Configuration File, then click (+) icon in the left bottom of the tool box, in the popup window, write the name and other input area, choose the configuration file, click Commit button.
  2. Select Templates>Template, then click (+) icon in the left bottom of the tool box, in the popup window, write the name and other input area, select the configuration file create in the first step, write the package name of the app which want to accept the template parameter.
  3. Select Terminals>Terminal, select the serial number of the POS you want to push template parameter.
  4. Select Config Application parameter icon in the bottom toolbox, in the popup window, click Add button in the left bottom, select the template parameter created and modify the value in the UI, then you can push it like push an app.

How to receive parameters in app

Please write the app to receive parameter file according as the following description. If the app is installed first time, you need to run it to make the BroadcastReceiver registered. After that, even if it does not run in background, it will self-triggered when you push parameter file and press "settings -> About POS -> POS Configuration -> Update now" on terminal.

Permission

 android.permission.CLOUDPOS_PUSHSERVICE

The application declares the permission in manifest.

Register BroadcastReceiver

Use android BroadcastReceiver to get pushing notice. Here is the demo:

<!-- permission -->
<uses-permission android:name="android.permission.CLOUDPOS_PUSHSERVICE" />

<!-- receiver -->
<receiver
android:name="com.xxx.xxx.receiver.XXBroadcastReceiver">
    <intent-filter>
    	<action android:name="your package name" />
</intent-filter>
</receiver>

public class ParamFileReceiver extends BroadcastReceiver {
		
		private static final String MSG_TYPE_PARAM = "param:";
		@Override
		public void onReceive(Context context, Intent intent) {
			String notification = intent.getStringExtra("notification");
			if (notification != null
	&&MSG_TYPE_PARAM.equals(notification.subSequence(0,
MSG_TYPE_PARAM.length()))) {
				// remove unnecessary characters
				String fileName = notification
                                      .substring(MSG_TYPE_PARAM.length());
			}
		}
	}
}

Please notice that the pushed information has a type field, it is used to distinguish the third-party information pushed.

Get downloaded file name

Use BroadcastReceiver to get parameter file's name. And use ContentResolver to get file stream. Here is the demo:

String URI_PARAM_FILE = "content://com.wizarpos.wizarviewagent.paramfilesprovider/file/";

Uri uri = Uri.parse(ParamFileProvider.URI_PARAM_FILE + fileName);
ContentResolver resolver = context.getContentResolver();
Reader reader = null;
try {
	reader = new InputStreamReader(resolver.openInputStream(uri));
} catch (FileNotFoundException e) {
e.printStackTrace();
}

The callback of the result of distribute parameters

Send the distributed result to WizarView, WizarView will decide weather the parameter file is completed. If completed, stop the push. Otherwise, it will push all the time.Here is the demo:

public static final String KEY_READED = "readed";
public static final String KEY_ERRLOG = "errlog";

String URI_PARAM_FILE = "content://com.wizarpos.wizarviewagent.paramfilesprovider/file/";

Uri uri = Uri.parse(ParamFileProvider.URI_PARAM_FILE + fileName);
ContentResolver resolver = context.getContentResolver();
ContentValues vaules = new ContentValues();

vaules.put("readed", true);
vaules.put("readed", false);
vaules.put("errlog", "Error in parameter information.Can not apply");

// give the result to the server
Uri resultUri = resolver.insert(uri, vaules);
if(resultUri == null){
	Log.e(APP_TAG, "param happen error , you need check log for modify this question!");
}

Sample

Please download the whole project demo