我使用 expo-linking 从应用程序获取路径。然后我在通知中打开链接。
responseListener.current =
Notifications.addNotificationResponseReceivedListener((response) => {
const linkExpo = LinkingExpo.createURL('/Starting')
// const navigation = useNavigation();
// alert()
Linking.openURL(linkExpo)
});
路径是这样的:
exp://u.expo.dev/[project-id]/--/Starting
我想在单击通知时打开应用程序(后台-前台-关闭)。该应用程序打开,但随后崩溃了。如何打开应用程序而不崩溃?
import React from 'react';
import { Handle, Position } from 'reactflow';
const CustomNode = ({ data, isConnectable }) => {
const toJson = () => {
const form = document.getElementById('dataForm');
const formData = new FormData(form);
const json = {};
formData.forEach((value, key) => {
json[key] = value;
});
document.getElementById('jsonOutput').innerText = JSON.stringify(json, null, 2);
};
return (
<div className="text-updater-node">
<Handle type="target" position={Position.Top} isConnectable={isConnectable} />
<form id="dataForm">
<label htmlFor="type">Type:</label>
<input type="text" id="type" name="type" /><br /><br />
<label htmlFor="baseUrl">BaseUrl:</label>
<input type="text" id="baseUrl" name="baseUrl" /><br /><br />
<label htmlFor="endpoint">Endpoint:</label>
<input type="text" id="endpoint" name="endpoint" /><br /><br />
<label htmlFor="httpMethod">HttpMethod:</label>
<select id="httpMethod" name="httpMethod">
<option value="GET">GET</option>
<option value="POST">POST</option>
<option value="PUT">PUT</option>
<option value="DELETE">DELETE</option>
<option value="PATCH">PATCH</option>
<option value="OPTIONS">OPTIONS</option>
</select><br /><br />
<label htmlFor="authType">Auth Type:</label>
<input type="text" id="authType" name="authType" /><br /><br />
<label htmlFor="authResourceID">Auth Resource ID:</label>
<input type="text" id="authResourceID" name="authResourceID" /><br /><br />
<label htmlFor="responseValidationFields">Response Validation Fields:</label>
<input type="text" id="responseValidationFields" name="responseValidationFields" /><br /><br />
<button type="button" onClick={toJson}>Submit</button>
</form>
<div id="jsonOutput" style={{ whiteSpace: 'pre-wrap', marginTop: '10px', padding: '10px', border: '1px solid #ddd', borderRadius: '5px' }}></div>
<Handle type="source" position={Position.Bottom} id="b" isConnectable={isConnectable} />
</div>
);
};
export default CustomNode;