Basics
env
pz.env
Environmental variables
attribute
string USER_DATA_PATH
User directory path in file system (Local path)
base64ToArrayBuffer
ArrayBuffer pz.base64ToArrayBuffer(string base64)
will Base64 String ArrayBuffer object
parameter
string base64
To translate into ArrayBuffer Object Base64 Character string
Return value
ArrayBuffer
ArrayBuffer object
sample code
const base64 = 'CxYh'
const arrayBuffer = pz.base64ToArrayBuffer(base64)arrayBufferToBase64
string pz.arrayBufferToBase64(ArrayBuffer arrayBuffer)
will ArrayBuffer Object conversion Base64 Character string
parameter
ArrayBuffer arrayBuffer
To convert Base64 String ArrayBuffer object
Return value
string
Base64 Character string
sample code
const arrayBuffer = new Uint8Array([11, 22, 33])
const base64 = pz.arrayBufferToBase64(arrayBuffer)base64ToTempFilePath
Basic library 1.3.9 is supported, iOS version 2.1.23, Android version 2.1.38
base64ToTempFilePath(Object object)
Save the base64 data of the image to the local sandbox and return the local cache path.
| Property | Type | The default value is | Required | Description |
|---|---|---|---|---|
| x | number | 0 | No | The upper-left abscissa of the area to be cropped is |
| y | number | 0 | No | The upper-left ordinate of the area to be cropped is |
| width | number | Canvas width - x | No | The width of the area to be cropped |
| height | number | Canvas height -y | No | The height of the area to be cropped is |
| destWidth | number | width x screen pixel density | No | The width of the output picture is |
| destHeight | number | height x screen pixel density | No | The height of the output picture is |
| base64Data | string | Yes | The image is converted into a base64 type string | |
| success | function | No | The interface calls the callback function | |
| fail | function | No | Interface call failed callback function | |
| complete | function | No | The callback function at the end of the interface call (the call succeeds or fails to execute |
object.success callback function
Parameter
Object res
| Property | Type | Description |
|---|---|---|
| tempFilePath | string | The local address of the picture |
fileToBase64
fileToBase64(Object object)
will file converted to Base64 Character string
Parameter
Object res
| Property | Type | Description |
|---|---|---|
| url | string | File address |
Return value
string
Base64 String
System
getSystemInfoSync
Supported since base library 1.3.9, iOS version 2.1.23, Android version 2.1.38
getSystemInfoSync()
The synchronous version of pz.getSystemInfo
getSystemInfoAsync
pz.getSystemInfoAsync(Object object)
Get system information asynchronously. Need some Phiz client version support, in the unsupported client, will use synchronization to return.
parameter
Object object
| attribute | type | Default values | Required | Introductions |
|---|---|---|---|---|
| success | function | no | Interface calls the successful callback function | |
| fail | function | no | Interface calls failed callback functions | |
| complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
object.success callback
parameter
Object res
| attribute | type | Introductions | Minimum version |
|---|---|---|---|
| brand | string | Equipment brand | 1.5.0 |
| model | string | Device model. New models will show unknown for a while, Phiz will adapt as soon as possible. | |
| pixelRatio | number | Device pixel ratio | |
| screenWidth | number | Screen width, in px | 1.1.0 |
| screenHeight | number | Screen height, in px | 1.1.0 |
| windowWidth | number | Available window width, unit px | |
| windowHeight | number | Available window height, in px | |
| statusBarHeight | number | Height of status bar in px | 1.9.0 |
| language | string | Language of Phiz settings | |
| version | string | Phiz version number | |
| system | string | Operating System and Version | |
| platform | string | Client platform | |
| fontSizeSetting | number | User font size in px. Phiz ClientI - Settings - Universal - Font SizeThe settings in | 1.5.0 |
| SDKVersion | string | Client base library version | 1.1.0 |
| benchmarkLevel | number | Equipment Performance Level (only Android)。 Values are: -2 or 0 (the device cannot run games), -1 (performance unknown),>= 1 (Device Performance Value, higher the value, better device performance, currently up to less than 50) | 1.8.0 |
| albumAuthorized | boolean | Allow Phiz to use the Photo Album switch (only iOS Effective) | 2.6.0 |
| cameraAuthorized | boolean | Switch that allows Phiz to use the camera | 2.6.0 |
| locationAuthorized | boolean | Allow Phiz to use location switch | 2.6.0 |
| microphoneAuthorized | boolean | Switch allowing Phiz to use microphone | 2.6.0 |
| notificationAuthorized | boolean | Switch that allows Phiz notifications | 2.6.0 |
| notificationAlertAuthorized | boolean | Allow Phiz to notify switches with reminders (only iOS Effective) | 2.6.0 |
| notificationBadgeAuthorized | boolean | Allow Phiz notifications with marked switches (only iOS Effective) | 2.6.0 |
| notificationSoundAuthorized | boolean | Allow Phiz to notify switches with sound (only iOS Effective) | 2.6.0 |
| bluetoothEnabled | boolean | Bluetooth System Switch | 2.6.0 |
| locationEnabled | boolean | Geographic Location System Switch | 2.6.0 |
| wifiEnabled | boolean | Wi-Fi System switch | 2.6.0 |
| safeArea | Object | A safe area in the positive direction of the vertical screen | 2.7.0 |
| locationReducedAccuracy | boolean | true Represents fuzzy positioning,false For precise positioning, only iOS Support | |
| theme | string | System current theme, with a value oflightordark, global configuration'darkmode': trueCan be obtained when otherwise undefined (Small games not supported) | 2.11.0 |
| enableDebug | boolean | Whether debugging is turned on. Available from the top right menu or pz.setEnableDebug Turn on debugging. | 2.15.0 |
| bundleId | string | The bundleId of the host app | 2.15.0 |
| deviceOrientation | string | Equipment direction |
safeArea Structure
| attribute | type | Introductions |
|---|---|---|
| left | number | Upper left abscissa of security area |
| right | number | Security area lower right abscissa |
| top | number | Top-left ordinate of security area |
| bottom | number | Lower right ordinate of security area |
| width | number | Width of security area, unit logical pixels |
| height | number | Height of Safe Area, Unit Logical Pixels |
theme Legal value
| value | Introductions | Minimum version |
|---|---|---|
| dark | Dark theme | |
| light | Light color theme |
host Structure
| attribute | type | Introductions |
|---|---|---|
| appId | string | host app Corresponding appId |
deviceOrientation Legal value
| value | Introductions | Minimum version |
|---|---|---|
| portrait | Vertical screen | |
| landscape | Horizontal screen |
sample code
Preview with Developer Tool
pz.getSystemInfoAsync({
success (res) {
console.log(res.model)
console.log(res.pixelRatio)
console.log(res.windowWidth)
console.log(res.windowHeight)
console.log(res.language)
console.log(res.version)
console.log(res.platform)
}
})getSystemInfo
Supported since base library 1.3.9, iOS version 2.1.23, Android version 2.1.38
getSystemInfo(Object object)
Gets system information.
Parameters
Object object
| Property | Type | Default | Required | Description |
|---|---|---|---|---|
| success | function | No | The callback function for a successful API call | |
| fail | function | No | The callback function for a failed API call | |
| complete | function | No | The callback function used when the API call completed (always executed whether the call succeeds or fails) |
object.success callback function Parameters
Object res
| Property | Type | Description |
|---|---|---|
| SDKVersion | string | Base library version for the Phiz app |
| runtimeSDKVersion | string | Applet SDK version number |
| brand | string | Device brand |
| model | string | Device model |
| pixelRatio | number | Device's pixel ratio |
| screenWidth | number | Screen width in px |
| screenHeight | number | Screen height in px |
| windowWidth | number | Available window width in px |
| windowHeight | number | Available window height in px |
| statusBarHeight | number | Status bar height in px |
| language | string | Language set in Phiz |
| version | string | Phiz version |
| bundleId | string | The bundleId of the host application |
| system | string | Operating system and version |
| platform | string | Client platform |
| inFinChat | boolean | Is it in the finchat applet environment |
| deviceId | string | Equipment identification |
Sample Code
pz.getSystemInfo({
success(res) {
console.log(res.model)
console.log(res.pixelRatio)
console.log(res.windowWidth)
console.log(res.windowHeight)
console.log(res.language)
console.log(res.version)
console.log(res.platform)
}
})Updates
getUpdateManager
Supported since base library 1.5.30, iOS version 2.5.6, Android version 2.8.76
ObtainGlobally uniqueThe version update manager for managing phizclip updates. Update on the phizclip mechanism, you can seeOperation mechanismDocumentation.
UpdateManager method
UpdateManager.applyUpdate() Force the phizclip to restart and use the new version. After the new version of the phizclip has been downloaded (i.e. received onUpdateReady Callback) call.
UpdateManager.onCheckForUpdate(function callback) Monitor the Phiz background request to check the update results event. Phiz automatically checks updates when the phizclip is cold started, without the developer taking the initiative to trigger.
UpdateManager.onUpdateReady(function callback) Listening phizclip has a version update event. Active client trigger download (no developer trigger), download success callback
UpdateManager.onUpdateFailed(function callback) Listen for phizclip to update failed events. phizclip has a new version, the client active trigger download (without developer trigger), download failure (may be network reasons, etc.) after the callback
sample code
const updateManager = pz.getUpdateManager()
updateManager.onCheckForUpdate(function (res) {
// Callback after requesting new version information
console.log(res.hasUpdate)
})
updateManager.onUpdateReady(function () {
pz.showModal({
title: 'Update tip ',
content: 'The new version is ready, reboot the app? ' ',
success: function (res) {
if (res.confirm) {
// The new version has been downloaded and calls applyUpdate Apply a new version and restart
updateManager.applyUpdate()
}
}
})
})
updateManager.onUpdateFailed(function () {
// New version download failed
})phizclip
getLaunchOptionsSync
Object pz.getLaunchOptionsSync() Gets the parameters for startup of the phizclip. and App.onLaunch The callback parameters of
Return value
Object
Starting parameter
| attribute | type | Introductions |
|---|---|---|
| path | string | Path to start phizclip (Code packet path) |
| query | Object | Start the phizclip query parameter |
| referrerInfo | Object | Source information. From another little program, Official Account message template or App Returns when entering the phizclip. Otherwise return {}。(See below for attention) |
referrerInfo Structure
| attribute | type | Introductions |
|---|---|---|
| appId | string | The appId of phizclip |
| extraData | Object | Source phizclip passed data |
getEnterOptionsSync
Object pz.getEnterOptionsSync()
Gets the parameters of this phizclip when it starts. If the current is a cold start, the return value is identical to the App.onLaunch Consistent with the callback parametersIf this is a hot start, the return value is identical to the App.onShow Consistent
Return value
Object
Starting parameter
| attribute | type | Introductions |
|---|---|---|
| path | string | Path to start phizclip (Code packet path) |
| query | Object | Start the phizclip query parameter |
| referrerInfo | Object | Source information. From another little program, Official Account message template or App Returns when entering the phizclip. Otherwise return {}。(See below for attention) |
referrerInfo Structure
| attribute | type | Introductions |
|---|---|---|
| appId | string | The appId of phizclip |
| extraData | Object | Source phizclip passed data |
onPageNotFound
pz.onPageNotFound(function callback)
There are no events on the page that the listening phizclip wants to open. This event is related to App.onPageNotFound The timing of the pullback was consistent
parameter
function callback
The callback function for the page that the phizclip opens does not exist
parameter
Object res
| attribute | type | Introductions |
|---|---|---|
| path | string | No path to the page (Code packet path) |
| query | Object | Open a page that does not exist query parameter |
| isEntryPage | boolean | Is the first page of this launch (for example, from the Share entrance, the first is the developer configuration share page) |
Be careful
- Developers can do page redirection in callbacks, but only in callbacksynchronizationProcessing, asynchronous processing such as
setTimeoutAsynchronous execution) is invalid. - If the developer does not call pz.onPageNotFound Binding listening, no declaration
App.onPageNotFound, When the jump page does not exist, will push the Phiz client native page there is no prompt page. - If the callback is redirected to another page that does not exist, the original page of Phiz client will be pushed into the page that is not there and there will be no second callback.
onError
pz.onError(function callback)
Listens for phizclip error events. Such as a script error or API Call error, etc. This event is related to App.onError The callback timing of the.
parameter
function callback
Callback function for phizclip error event
parameter
string error
Error message, including stack
onAppShow
pz.onAppShow(function callback)
Listen to the phizclip cut foreground events. This event is related to App.onShow The callback parameters of
parameter
function callback
Callback Function for phizclip to Cut Foreground Events
parameter
Object res
| attribute | type | Introductions |
|---|---|---|
| path | string | phizclip cut the foreground path (Code packet path) |
| query | Object | phizclip cut the front desk query parameter |
| referrerInfo | Object | Source information. From another little program, Official Account message template or App Returns when entering the phizclip. Otherwise return {}。(See below for attention) |
referrerInfo Structure
| attribute | type | Introductions |
|---|---|---|
| appId | string | The appId of phizclip |
| extraData | Object | Source phizclip passed data |
Be careful
Partial Version NoreferrerInfoWill return when undefinedRecommended for use options.referrerInfo && options.referrerInfo.appId To judge.
onAppHide
pz.onAppHide(function callback)
Listen to the phizclip cut background events. This event is related to App.onHide The timing of the pullback was consistent.
parameter
function callback
Callback Function for Background Events
offPageNotFound
pz.offPageNotFound(function callback)
The page to be opened by the unlisten phizclip does not have an event
parameter
function callback
The callback function for the page that the phizclip opens does not exist
offError
pz.offError(function callback)
Cancels listening for phizclip error events
parameter
function callback
Callback function for phizclip error event
offAppShow
pz.offAppShow(function callback)
Cancel the monitor phizclip to cut the foreground event
parameter
function callback
Callback Function for phizclip to Cut Foreground Events
offAppHide
pz.offAppHide(function callback)
Cancel listening phizclip to cut background event
parameter
function callback
Callback Function for Background Events
onThemeChange
pz.onThemeChange(function callback)
Listen for system topic change events
parameter
function callback
Callback function for the system topic change event
onUnhandledRejection
pz.onUnhandledRejection(function callback)
Listen for unprocessed Promise rejection events
parameter
function callback
Callback function for an unhandled Promise rejection event
offUnhandledRejection
pz.offUnhandledRejection(function callback)
Cancel listening for unprocessed Promise rejection events
parameter
function callback
onUnhandledRejection Incoming callback function. If this argument is not passed, all listening functions are removed.
offThemeChange
pz.offThemeChange(function callback)
Cancels listening for system topic change events
parameter
function callback
onThemeChange The callback function passed in. If this parameter is not passed, all listener functions are removed.
debugging
setEnableDebug
pz.setEnableDebug(Object object)
Sets whether the debug switch is turned on. This switch also works for the official version
parameter
Object object
| attribute | type | Default values | Required | Introductions |
|---|---|---|---|---|
| enableDebug | boolean | yes | Turn on debugging | |
| success | function | no | Interface calls the successful callback function | |
| fail | function | no | Interface calls failed callback functions | |
| complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) |
sample code
// Turn on debugging
pz.setEnableDebug({
enableDebug: true
})
// Close debugging
pz.setEnableDebug({
enableDebug: false
})Tips
- In the official version to open debugging there is a way that is first in the development version or the experience version of the open debugging, and then cut to the formal version can see vConsole.
console
Prints logs to the debugging console. The "console" is a global object and can be accessed directly. In the Phiz app, logs are output to vConsole.
console.debug()
Prints the "debug" log to the debugging panel.
console.error()
Prints the "error" log to the debugging panel.
console.group()
Creates a new group in the debugging panel.
console.groupEnd()
Ends a group created by console.group.
console.info()
Prints the "info" log to the debugging panel.
console.log()
Prints the "log" log to the debugging panel.
console.warn()
Prints the "warn" log to the debugging panel.
LogManager
Log manager instance
LogManager.debug()
write debug journal
LogManager.info()
write info journal
LogManager.log()
write log journal
LogManager.warn()
write warn journal
RealtimeLogManager
Real - time log manager instance
RealtimeLogManager.info()
write info Logging is not supported in plugins
RealtimeLogManager.warn()
write warn Logging is not supported in plugins
RealtimeLogManager.error()
write error Logging is not supported in plugins
RealtimeLogManager.setFilterMsg(string msg)
Set filter keywords, temporarily do not support the use of
RealtimeLogManager.addFilterMsg(string msg)
Add filter keywords, temporarily not supported in plugin use
Account information
getAccountInfoSync
Gets the current account information. Online phizclip version number is only available in the official version of the phizclip, development version and experience version can not be obtained
Return value
Object object
| attribute | type | Default values | Required | Introductions |
|---|---|---|---|---|
| miniProgram | Object | yes | phizclip account information |
Object miniProgram
| attribute | type | Introductions |
|---|---|---|
| appId | string | phizclip appId |
| envVersion | string | phizclip version |