如何在ServiceM8 UI中添加按钮启动应用并传递Job UUID或工单编号?
Hey Chad, great question! Let's break down how to integrate your wrapper web app (and iOS native app) with ServiceM8, including passing job identifiers and adding custom UI buttons:
1. Launch Your Wrapper Web App from ServiceM8 Job Cards (with Job UUID/Number)
ServiceM8 offers two straightforward ways to launch your web app from a job card while passing the required job parameters:
Custom Actions (Best for External Launch)
Head to your ServiceM8 admin dashboard and create a Custom Action for jobs. Configure the action's target URL to point to your web app, using ServiceM8's built-in dynamic variables to inject the job UUID and number:
https://your-web-app-url.com/start?job_uuid={{job_uuid}}&job_number={{job_number}}
When users select this action from the job card's "Actions" menu, ServiceM8 will automatically replace {{job_uuid}} and {{job_number}} with the current job's values, launching your app with the right context. You can even set the action to display as a button directly on the job details page toolbar for easier access.
Embedded Web View (For Wrapper App Integration)
Since you're building a wrapper web app, you can embed it directly into ServiceM8's job details page (as a custom tab or sidebar widget). ServiceM8's JavaScript SDK will automatically pass job context to your app, so you can fetch the UUID/number with a simple call:
// Use ServiceM8's SDK to get job context sm8.getContext(function(context) { const jobUuid = context.job_uuid; const jobNumber = context.job_number; // Initialize your app with these parameters });
2. Adding Custom Buttons to the ServiceM8 UI
You have two options to add buttons that launch your app:
Custom Action Buttons
As mentioned above, when creating a Custom Action, enable the "Show as button" option. This adds a dedicated button to the job details page's top toolbar, which users can click to instantly launch your web app with the job's parameters.
Plugin SDK for Advanced UI Customization
If you need more control over the button's placement or behavior, use ServiceM8's Plugin SDK to build a custom plugin. The SDK lets you inject UI elements into the job page, listen for job load events to capture the UUID/number, and trigger your app launch when the button is clicked.
3. Launching Your iOS Native App with Job UUID
To open your iOS app from ServiceM8 (and pass the job UUID), use either URL Schemes or Universal Links:
URL Schemes
First, register a custom URL scheme for your iOS app (e.g., yourapp://). Then, create a Custom Action in ServiceM8 with a URL like:
yourapp://launch?job_uuid={{job_uuid}}
When users tap this button in the ServiceM8 iOS app, it will open your native app. You can parse the URL in your app's AppDelegate or SceneDelegate to extract the job_uuid parameter.
Universal Links (Recommended)
For a smoother user experience (no "Open in App" prompts), use Universal Links. Configure your domain with an Apple App Site Association file, link it to your iOS app via the "Associated Domains" entitlement, then use a web URL in your ServiceM8 action:
https://your-domain.com/launch?job_uuid={{job_uuid}}
If your app is installed, tapping this link will open it directly with the parameter; if not, it will fall back to your web app.
内容的提问来源于stack exchange,提问作者Chad Lewis

