If anyone want callback data when click on live activity widget the I have made some adjustment to get data from Linking
Also I worked on endLiveActivity method because its not working properly
Here I have add one more props as data you call pass any data by converting into string and get by Linking
void createLiveActivity({
title: title || "your tital",
timerTitle: body || 'Quiz countdown ongoing.\nTime left:',
buttonTitle: 'Open App',
imageName: Images.ic_app_launcher,
endDateTime: upComingEventTime, // Date object can be used too
timerColor: '#ff0000',
data:JSON.stringify(remoteMessage)
})
.then((id: string | undefined) => {
console.log("createLiveActivity=>", id);
})
You will get data in
const initialUrl = await Linking.getInitialURL()
if (initialUrl && initialUrl?.includes("fanizm://live-activity")) {
const liveActivityObj= await decodeFanizmURL(initialUrl)
console.log("liveActivityObj=>",liveActivityObj)
}
And decodeFanizmURL function
function decodeFanizmURL(url:string) {
try {
const dataStartIndex = url.indexOf('?data=');
if (dataStartIndex === -1) return null;
const encodedData = url.slice(dataStartIndex + 6);
const withoutOptional = encodedData
.replace('Optional(', '')
.replace(/\)$/, '')
.trim();
const decodedString = decodeURIComponent(withoutOptional);
const withoutOuterQuotes = decodedString.replace(/^"(.*)"$/, '$1');
const unescapedString = withoutOuterQuotes.replace(/\\"/g, '"');
const data = JSON.parse(unescapedString);
return data;
} catch (error) {
console.error('Error decoding URL at step:', error);
return null;
}
}
export default decodeFanizmURL;
Here my app name is Fanizm you can change according to your app name
I have sending 2 patch file, Please replace Fanizm by your app name from patch file also
@txo+live-activity-countdown-react-native+1.0.11.patch
@txo+live-activity-countdown-view-react-native+1.1.0.patch
For any help you can connect with me by 18rohitbabu@gmail.com.
:)
If anyone want callback data when click on live activity widget the I have made some adjustment to get data from Linking
Also I worked on endLiveActivity method because its not working properly
Here I have add one more props as data you call pass any data by converting into string and get by Linking
You will get data in
And decodeFanizmURL function
Here my app name is Fanizm you can change according to your app name
I have sending 2 patch file, Please replace Fanizm by your app name from patch file also
@txo+live-activity-countdown-react-native+1.0.11.patch
@txo+live-activity-countdown-view-react-native+1.1.0.patch
For any help you can connect with me by 18rohitbabu@gmail.com.
:)