DeltaBreen对NativeScript的帮助
在你的应用程序中的帮助台:支持表单和用户自己的票,与你的团队的答复,在屏幕上的 原生脚本应用,支持纯原生脚本、Angular、Vue、Svelte或React。它在web视图中显示帮助自己的表单 你的应用程序在没有你的版本的情况下得到我们的修复,并将它的事件交还给你的代码。
npm install @deltabreen/help-nativescript
在Android上,它添加了 androidx.webkit 到你的应用程序,它保留了用户和表单的事件
页面的来源。
在你的网站页面上
在你的网站上创建一个页面,只包含表单和用户自己的门票,地址如下
https://acme.com/app-support (你的网站的 安装 TAB有它,用你的键,当网站是 手机应用程序)。
然后用 HelpView:
<!-- Plain NativeScript: support-page.xml -->
<Page xmlns="http://schemas.nativescript.org/tns.xsd" xmlns:help="@deltabreen/help-nativescript">
<help:HelpView src="https://acme.com/app-support" token="{{ token }}" sent="{{ onSent }}" />
</Page>
在框架中,注册一次视图,然后像使用其他视图一样使用它:
// Angular, in main.ts; the component that shows it lists NO_ERRORS_SCHEMA in its schemas
import { registerElement } from '@nativescript/angular'
import { HelpView } from '@deltabreen/help-nativescript'
registerElement('HelpView', () => HelpView)
// <HelpView src="https://acme.com/app-support" [token]="token" (sent)="onSent($event)"></HelpView>
// Vue, in app.js
import { registerElement } from 'nativescript-vue'
import { HelpView } from '@deltabreen/help-nativescript'
registerElement('HelpView', () => HelpView)
// <HelpView src="https://acme.com/app-support" :token="token" @sent="onSent" />
// Svelte Native, in app.ts
import { registerNativeViewElement } from 'svelte-native/dom'
import { HelpView } from '@deltabreen/help-nativescript'
registerNativeViewElement('helpView', () => HelpView)
// <helpView src="https://acme.com/app-support" token={token} on:sent={onSent} />
// React NativeScript
import { registerElement } from 'react-nativescript'
import { HelpView } from '@deltabreen/help-nativescript'
registerElement('helpView', () => HelpView)
// <helpView src="https://acme.com/app-support" token={token} onSent={onSent} />
给它的高度,它应该填充,像任何视图:一行 GridLayout 与 *,或整页。你的网站
验证域名是什么让你的活键工作,因为它在网站本身。链接到您的网站留在
应用程序;其他任何东西,比如团队回复中的文件,都会在手机浏览器中打开。的表单按钮
添加文件将打开手机自己的选择器。
在iPhone上,这个选择器提供“拍照”功能,iOS会关闭一个打开相机的应用程序,而不会说明原因。添加这个
来 App_Resources/iOS/Info.plist, iOS在询问以下问题时应该显示:
<key>NSCameraUsageDescription</key>
<string>To send a photo to support.</string>
登录用户
一个用户登录到你的应用程序,不输入他们的电子邮件,就可以看到他们自己的票和你的票
回答。你的 服务器 签署一个简短的令牌,说明他们是谁,与您的网站的秘密
(该指南 有代码)。每次都向服务器请求一个
屏幕打开并将其设置为 token;它在脚本运行之前被传递给页面,而不是传递给其他站点。没有
首先,表格将他们视为客人。
你的应用程序没有网站
离开 src 给出你的网站的关键字:视图携带页面本身。在门户中,选择 我的应用没有
网站 为网站。你的实时密钥对登录到你的应用程序的人有效,如果你打开它,对于
有人有你的应用吗?,通过为电话制作的键,第一次支持打开:
import { deviceKey } from '@deltabreen/help-nativescript'
export const help = { siteKey: 'pk_live_…', deviceKey: deviceKey() }
// <help:HelpView siteKey="{{ help.siteKey }}" deviceKey="{{ help.deviceKey }}" />
deviceKey() 创建一次密钥并将其保存在应用程序的设置中。将其保存在Keychain或Keystore中
相反,把它递给我 new SecureStorage() 从 @nativescript/secure-storage. 给出一个登录用户的 token 而不是
在有密钥的地方:我们建议尽可能通过您自己的服务器登录您的用户,因为密钥在一个
App可以拿出来,只有登录的用户不能补。
没有网站, show 选择表单、票证或两者(默认值),和 lang, accent, labels, subject
和 fields 元素是自己的吗 嵌入指南.
一、 deviceKey 的 null 等待:页面在设置后加载。
pageCss 是你自己的CSS页面,在我们之后:它的背景和类型,并通过其自定义的形式
属性和部件。把一屏票放在另一个位置, show="tickets":
<help:HelpView siteKey="pk_live_…" show="form" pageCss="body { background: #0f1115; color: #e8e8e8 } db-help-form { --dbh-accent: #7c5cff; --dbh-radius: 14px }" />
<help:HelpView siteKey="pk_live_…" show="tickets" pageCss="db-help-tickets::part(ticket-preview) { opacity: .6 }" />
事件
每个事件的 detail 上面写着发生了什么:
| 事件 | 当 |
|---|---|
sent | 发送了一条消息: { number } |
error | 它不可能是: { code } |
replied | 他们回答了一张罚单: { number } |
closed | 他们标记了一张解决了的罚单: { number } |
rated | 他们给了1分: { number, stars } |
unread | 你的团队有多少回复他们没有读过? { unread } |
view | 他们打开的票证,或者列表为空: { ticket } |
helpView.on('unread', ({ detail }) => (badge.text = String(detail.unread)))
在屏幕关闭时告诉人们回复,a webhook (箴 可以发送应用程序自己的通知。
你自己的网页视图
helpPage({ siteKey, … }, { token, deviceKey }) 页面是一个没有网站显示的应用程序吗 helpScript({ token, deviceKey }) 在网站页面脚本之前运行的内容。页面的事件以JSON形式到达 deltahelp 命名
每个,张贴至 window.webkit.messageHandlers.deltahelp 在iPhone或 window.DeltaHelpBridge 在Android上。