概要
方法
PromptOptIn():() |
API 参考
方法
CanPromptOptInAsync
返回
代码示例
本地脚本 - 通知权限提示实现
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)
end
-- 监听选项提示关闭事件
ExperienceNotificationService.OptInPromptClosed:Connect(function()
print("选项提示已关闭")
end)PromptOptIn
ExperienceNotificationService:PromptOptIn():()
返回
()
代码示例
本地脚本 - 通知权限提示实现
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)
end
-- 监听选项提示关闭事件
ExperienceNotificationService.OptInPromptClosed:Connect(function()
print("选项提示已关闭")
end)活动
OptInPromptClosed
代码示例
本地脚本 - 通知权限提示实现
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)
end
-- 监听选项提示关闭事件
ExperienceNotificationService.OptInPromptClosed:Connect(function()
print("选项提示已关闭")
end)