Skip to content

Commit 20282d7

Browse files
committed
Implement areNotificationsEnabled
Based on DimaUndSo Pull Request
1 parent 1674f3d commit 20282d7

14 files changed

Lines changed: 144 additions & 6 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# notifications.areNotificationsEnabled()
2+
3+
> --------------------- ------------------------------------------------------------------------------------------
4+
> __Type__ [Function][api.type.Function]
5+
> __Return value__ [String][api.type.String]
6+
> __Revision__ [REVISION_LABEL](REVISION_URL)
7+
> __Keywords__ notification, notifications, subscribe
8+
> __See also__ [notifications.*][plugin.notifications-v2]
9+
> --------------------- ------------------------------------------------------------------------------------------
10+
11+
12+
## Overview
13+
14+
Returns true if notifications for the app are enabled, or false if not.
15+
16+
17+
## Syntax
18+
19+
notifications.areNotificationsEnabled()
20+
21+
22+
## Example
23+
24+
``````lua
25+
local notifications = require( "plugin.notifications.v2" )
26+
27+
print( notifications.areNotificationsEnabled() )
28+
``````

docs/notifications-v2/index.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ For Android, all __new__ apps, or existing apps being updated with push notifica
3939

4040
#### [notifications.registerForPushNotifications()][plugin.notifications-v2.registerForPushNotifications]
4141

42+
#### [notifications.areNotificationsEnabled()][plugin.notifications-v2.areNotificationsEnabled]
4243

4344
## Project Settings
4445

6 KB
Binary file not shown.
1.13 KB
Binary file not shown.
35.2 KB
Binary file not shown.
28.2 KB
Binary file not shown.

plugins/2023.3693/iphone/metadata.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ local metadata =
1010
}
1111
}
1212

13-
1413
return metadata

plugins/2023.3693/mac-sim/plugin_notifications_v2.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ function lib.cancelNotification()
4242
showWarning("notifications.cancelNotification()")
4343
end
4444

45+
function lib.areNotificationsEnabled()
46+
showWarning("notifications.areNotificationsEnabled()")
47+
end
48+
4549
-------------------------------------------------------------------------------
4650
-- END
4751
-------------------------------------------------------------------------------

plugins/2023.3693/win32-sim/plugin_notifications_v2.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ function lib.cancelNotification()
4242
showWarning("notifications.cancelNotification()")
4343
end
4444

45+
function lib.areNotificationsEnabled()
46+
showWarning("notifications.areNotificationsEnabled()")
47+
end
48+
4549
-------------------------------------------------------------------------------
4650
-- END
4751
-------------------------------------------------------------------------------

src/Corona/main.lua

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ local subTitle = display.newText {
277277
subTitle:setTextColor( 0.2, 0.2, 0.2 )
278278
subTitle.x, subTitle.y = display.contentCenterX, 60
279279

280-
eventDataTextBox = native.newTextBox( display.contentCenterX, display.contentHeight - 50, display.contentWidth - 10, 100)
280+
eventDataTextBox = native.newTextBox( display.contentCenterX, display.contentHeight - 20, display.contentWidth - 10, 100)
281281
eventDataTextBox.placeholder = "Event data will appear here"
282282
eventDataTextBox.hasBackground = false
283283

@@ -314,7 +314,7 @@ local subscribeToNewsTopic = widget.newButton {
314314
notifications.subscribe("news")
315315
end
316316
}
317-
subscribeToNewsTopic.x, subscribeToNewsTopic.y = display.contentCenterX, 150
317+
subscribeToNewsTopic.x, subscribeToNewsTopic.y = display.contentCenterX, 130
318318

319319
local unsubscribeFromNewsTopic = widget.newButton {
320320
label = "Unsubscribe from News",
@@ -367,6 +367,17 @@ local getDeviceTokenButton = widget.newButton {
367367
}
368368
getDeviceTokenButton.x, getDeviceTokenButton.y = display.contentCenterX, cancelLocalNotification.y + 60
369369

370+
local areNotificationsEnabledButton = widget.newButton {
371+
label = "Are notifications enabled",
372+
width = 200,
373+
height = 40,
374+
labelColor = { default={ 0, 0, 0 }, over={ 0.7, 0.7, 0.7 } },
375+
onRelease = function(event)
376+
print("notifications enabled", notifications.areNotificationsEnabled())
377+
end
378+
}
379+
areNotificationsEnabledButton.x, areNotificationsEnabledButton.y = display.contentCenterX, getDeviceTokenButton.y + 40
380+
370381
-- local notifications: check for launch args and call listener
371382
if ( launchArgs and launchArgs.notification ) then
372383
print(">>>> launching app from notification...")

0 commit comments

Comments
 (0)