Experience Notification Service
API Reference
Methods
Can Prompt Opt In Async
Returns
Code Samples
LocalScript - Notification Permission Prompt Implementation
local ExperienceNotificationService = game:GetService("ExperienceNotificationService")
-- Function to check whether the player can be prompted to enable notifications
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)
if not success then
warn("Failed to prompt opt-in:", errorMessage)
end
end
-- Listen to opt-in prompt closed event
ExperienceNotificationService.OptInPromptClosed:Connect(function()
print("Opt-in prompt closed")
end)Prompt Opt In
Experience Notification Service: Prompt Opt In():()
Returns
()
Code Samples
LocalScript - Notification Permission Prompt Implementation
local ExperienceNotificationService = game:GetService("ExperienceNotificationService")
-- Function to check whether the player can be prompted to enable notifications
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)
if not success then
warn("Failed to prompt opt-in:", errorMessage)
end
end
-- Listen to opt-in prompt closed event
ExperienceNotificationService.OptInPromptClosed:Connect(function()
print("Opt-in prompt closed")
end)Events
Opt In Prompt Closed
Code Samples
LocalScript - Notification Permission Prompt Implementation
local ExperienceNotificationService = game:GetService("ExperienceNotificationService")
-- Function to check whether the player can be prompted to enable notifications
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)
if not success then
warn("Failed to prompt opt-in:", errorMessage)
end
end
-- Listen to opt-in prompt closed event
ExperienceNotificationService.OptInPromptClosed:Connect(function()
print("Opt-in prompt closed")
end)