Lớp công cụ
ExperienceNotificationService
*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.
Tài Liệu Tham Khảo API
Phương Pháp
CanPromptOptInAsync
Lợi Nhuận
Mẫu mã
LocalScript - Triển khai lời nhắc quyền thông báo
local ExperienceNotificationService = game:GetService("ExperienceNotificationService")
-- Hàm để kiểm tra xem người chơi có thể được nhắc để bật thông báo hay không
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
-- Lắng nghe sự kiện lời nhắc chọn tham gia bị đóng
ExperienceNotificationService.OptInPromptClosed:Connect(function()
print("Lời nhắc chọn tham gia đã bị đóng")
end)PromptOptIn
ExperienceNotificationService:PromptOptIn():()
Lợi Nhuận
()
Mẫu mã
LocalScript - Triển khai lời nhắc quyền thông báo
local ExperienceNotificationService = game:GetService("ExperienceNotificationService")
-- Hàm để kiểm tra xem người chơi có thể được nhắc để bật thông báo hay không
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
-- Lắng nghe sự kiện lời nhắc chọn tham gia bị đóng
ExperienceNotificationService.OptInPromptClosed:Connect(function()
print("Lời nhắc chọn tham gia đã bị đóng")
end)Sự Kiện
OptInPromptClosed
Mẫu mã
LocalScript - Triển khai lời nhắc quyền thông báo
local ExperienceNotificationService = game:GetService("ExperienceNotificationService")
-- Hàm để kiểm tra xem người chơi có thể được nhắc để bật thông báo hay không
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
-- Lắng nghe sự kiện lời nhắc chọn tham gia bị đóng
ExperienceNotificationService.OptInPromptClosed:Connect(function()
print("Lời nhắc chọn tham gia đã bị đóng")
end)