學習
引擎類別
ExperienceNotificationService
無法建立
服務
未複製

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡


概要
繼承成員

API 參考
方法
CanPromptOptInAsync
暫停
功能: Players, Social
ExperienceNotificationService:CanPromptOptInAsync():boolean
返回
範例程式碼
LocalScript - 通知權限提示實現
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():()
返回
()
範例程式碼
LocalScript - 通知權限提示實現
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
範例程式碼
LocalScript - 通知權限提示實現
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 是我們在美國及其他國家地區的部分註冊與未註冊商標。