学习
引擎类
ExperienceNotificationService
无法创建
服务
未复制

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处


概要
继承成员

API 参考
方法
CanPromptOptInAsync
暂停
功能: Players, Social
ExperienceNotificationService:CanPromptOptInAsync():boolean
返回
代码示例
本地脚本 - 通知权限提示实现
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
功能: Players, Social
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
功能: Players, Social
ExperienceNotificationService.OptInPromptClosed():RBXScriptSignal
代码示例
本地脚本 - 通知权限提示实现
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)

©2026 Roblox Corporation、Roblox、Roblox 标志及 Powering Imagination 是我们在美国及其他国家或地区的注册与未注册商标。