Experience Notification Service
摘要
方法
PromptOptIn():() |
API 参考
方法
Can Prompt Opt In Async
返回
代码示例
本地脚本 - 通知权限提示实现
local ExperienceNotificationService = game:GetService("ExperienceNotificationService")
-- 检查玩家是否可以被提示启用通知的函数
local function canPromptOptIn()
local success, canPrompt = pcall(function()
return ExperienceNotificationService:CanPromptOptInAsync()
end)
return success and canPrompt
end
local canPrompt = canPromptOptIn()
if canPrompt then
local success, errorMessage = pcall(function()
ExperienceNotificationService:PromptOptIn()
end)
if not success then
warn("提示启用失败:", errorMessage)
end
end
-- 监听启用提示关闭事件
ExperienceNotificationService.OptInPromptClosed:Connect(function()
print("启用提示已关闭")
end)Prompt Opt In
Experience Notification Service: Prompt Opt In():()
返回
()
代码示例
本地脚本 - 通知权限提示实现
local ExperienceNotificationService = game:GetService("ExperienceNotificationService")
-- 检查玩家是否可以被提示启用通知的函数
local function canPromptOptIn()
local success, canPrompt = pcall(function()
return ExperienceNotificationService:CanPromptOptInAsync()
end)
return success and canPrompt
end
local canPrompt = canPromptOptIn()
if canPrompt then
local success, errorMessage = pcall(function()
ExperienceNotificationService:PromptOptIn()
end)
if not success then
warn("提示启用失败:", errorMessage)
end
end
-- 监听启用提示关闭事件
ExperienceNotificationService.OptInPromptClosed:Connect(function()
print("启用提示已关闭")
end)活动
Opt In Prompt Closed
代码示例
本地脚本 - 通知权限提示实现
local ExperienceNotificationService = game:GetService("ExperienceNotificationService")
-- 检查玩家是否可以被提示启用通知的函数
local function canPromptOptIn()
local success, canPrompt = pcall(function()
return ExperienceNotificationService:CanPromptOptInAsync()
end)
return success and canPrompt
end
local canPrompt = canPromptOptIn()
if canPrompt then
local success, errorMessage = pcall(function()
ExperienceNotificationService:PromptOptIn()
end)
if not success then
warn("提示启用失败:", errorMessage)
end
end
-- 监听启用提示关闭事件
ExperienceNotificationService.OptInPromptClosed:Connect(function()
print("启用提示已关闭")
end)