概要
方法
PromptOptIn():() |
API 參考
方法
CanPromptOptInAsync
返回
範例程式碼
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
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
範例程式碼
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)