远程交互式推送通知 - 如何?
Remote Interactive Push Notifications - HOW?
TL;DR 如何通过 Expo 的推送发送交互式通知 API
请提供以下内容:
SDK版本:40
平台(Android/iOS/web/all):全部
使用以下代码,我创建了一个类别并使用 getNotificationCategoriesAsync
,确认它的存在。
import Constants from "expo-constants";
import * as Notifications from "expo-notifications";
// Set up Category
Notifications.setNotificationCategoryAsync("basic", [
{ identifier: "Yes", buttonTitle: "Yes " },
{ identifier: "No", buttonTitle: "No " },
])
// Check category is there
Notifications.getNotificationCategoriesAsync().then((categories) => {
console.log(categories)});
// Get experienceId
experienceId = Constants.manifest.id;
console.log(experienceId);
在 API 方面,我使用了下面的请求并将 @username/appName 替换为上面记录的内容 (experienceId)。我已经在 ios 和 android 的真实设备和模拟器上进行了尝试,即使通知确实发送了,它也缺少交互方面。
curl -H "Content-Type: application/json" -X POST "https://exp.host/--/api/v2/push/send" -d '{
"to": "ExponentPushToken[XXXXXXXXXXXXXXXX]",
"title":"hello",
"body": "world",
"_category":"@username/appName:basic",
}'
我也试过用“categoryId”或“categoryIdentifier”或“category”替换“_category”。 None 其中有效。有没有人能够成功做到这一点!如果有怎么办!提前致谢
你真的很接近,experienceId 和类别用连字符“-”连接。查看 iOS 上的源代码,您可以看到格式字符串:
curl -H "Content-Type: application/json" -X POST "https://exp.host/--/api/v2/push/send" -d '{
"to": "ExponentPushToken[XXXXXXXXXXXXXXXX]",
"title":"hello",
"body": "world",
"_category":"@username/appName-basic",
}'
TL;DR 如何通过 Expo 的推送发送交互式通知 API
请提供以下内容:
SDK版本:40
平台(Android/iOS/web/all):全部
使用以下代码,我创建了一个类别并使用 getNotificationCategoriesAsync
,确认它的存在。
import Constants from "expo-constants";
import * as Notifications from "expo-notifications";
// Set up Category
Notifications.setNotificationCategoryAsync("basic", [
{ identifier: "Yes", buttonTitle: "Yes " },
{ identifier: "No", buttonTitle: "No " },
])
// Check category is there
Notifications.getNotificationCategoriesAsync().then((categories) => {
console.log(categories)});
// Get experienceId
experienceId = Constants.manifest.id;
console.log(experienceId);
在 API 方面,我使用了下面的请求并将 @username/appName 替换为上面记录的内容 (experienceId)。我已经在 ios 和 android 的真实设备和模拟器上进行了尝试,即使通知确实发送了,它也缺少交互方面。
curl -H "Content-Type: application/json" -X POST "https://exp.host/--/api/v2/push/send" -d '{
"to": "ExponentPushToken[XXXXXXXXXXXXXXXX]",
"title":"hello",
"body": "world",
"_category":"@username/appName:basic",
}'
我也试过用“categoryId”或“categoryIdentifier”或“category”替换“_category”。 None 其中有效。有没有人能够成功做到这一点!如果有怎么办!提前致谢
你真的很接近,experienceId 和类别用连字符“-”连接。查看 iOS 上的源代码,您可以看到格式字符串:
curl -H "Content-Type: application/json" -X POST "https://exp.host/--/api/v2/push/send" -d '{
"to": "ExponentPushToken[XXXXXXXXXXXXXXXX]",
"title":"hello",
"body": "world",
"_category":"@username/appName-basic",
}'