Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cordova-plugin-local-notifications
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nabil Sadki
cordova-plugin-local-notifications
Commits
1552ffc9
Commit
1552ffc9
authored
Aug 24, 2017
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented new trigger property for iOS
parent
44a0da5c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
25 deletions
+17
-25
APPNotificationOptions.m
src/ios/APPNotificationOptions.m
+17
-25
No files found.
src/ios/APPNotificationOptions.m
View file @
1552ffc9
...
...
@@ -61,18 +61,6 @@
#pragma mark Properties
/**
* The type for the notification.
*
* @return [ NSString* ]
*/
-
(
NSString
*
)
triggerType
{
NSString
*
type
=
[
dict
objectForKey
:
@"trigger"
];
return
type
.
length
?
type
:
@"normal"
;
}
/**
* The ID for the notification.
*
* @return [ NSNumber* ]
...
...
@@ -280,12 +268,12 @@
*/
-
(
UNNotificationTrigger
*
)
trigger
{
NSString
*
type
=
[
self
triggerType
];
NSString
*
type
=
[
self
valueForTriggerOption
:
@"type"
];
if
([
type
isEqualToString
:
@"location"
])
return
[
self
triggerWithRegion
];
if
(
!
[
type
isEqualToString
:
@"
date
"
])
if
(
!
[
type
isEqualToString
:
@"
calendar
"
])
NSLog
(
@"Unknown type: %@"
,
type
);
if
([
self
isRepeating
])
...
...
@@ -315,6 +303,11 @@
#pragma mark -
#pragma mark Private
-
(
id
)
valueForTriggerOption
:
(
NSString
*
)
key
{
return
[[
dict
objectForKey
:
@"trigger"
]
objectForKey
:
key
];
}
/**
* The date when to fire the notification.
*
...
...
@@ -322,8 +315,7 @@
*/
-
(
NSDate
*
)
triggerDate
{
double
timestamp
=
[[
dict
objectForKey
:
@"at"
]
doubleValue
];
double
timestamp
=
[[
self
valueForTriggerOption
:
@"at"
]
doubleValue
];
return
[
NSDate
dateWithTimeIntervalSince1970
:
timestamp
];
}
...
...
@@ -335,7 +327,7 @@
*/
-
(
BOOL
)
isRepeating
{
id
every
=
[
dict
objectForKey
:
@"every"
];
id
every
=
[
self
valueForTriggerOption
:
@"every"
];
if
([
every
isKindOfClass
:
NSString
.
class
])
return
((
NSString
*
)
every
).
length
>
0
;
...
...
@@ -364,7 +356,7 @@
*/
-
(
UNNotificationTrigger
*
)
repeatingTrigger
{
id
every
=
[
dict
objectForKey
:
@"every"
];
id
every
=
[
self
valueForTriggerOption
:
@"every"
];
if
([
every
isKindOfClass
:
NSString
.
class
])
return
[
self
triggerWithDateMatchingComponents
];
...
...
@@ -382,7 +374,7 @@
*/
-
(
UNTimeIntervalNotificationTrigger
*
)
triggerWithTimeInterval
{
long
interval
=
[[
dict
objectForKey
:
@"every"
]
longValue
];
long
interval
=
[[
self
valueForTriggerOption
:
@"every"
]
longValue
];
if
(
interval
<
60
)
{
NSLog
(
@"time interval must be at least 60 if repeating"
);
...
...
@@ -438,8 +430,8 @@
*/
-
(
UNLocationNotificationTrigger
*
)
triggerWithRegion
{
NSArray
*
center
=
[
dict
objectForKey
:
@"center"
];
double
radius
=
[[
dict
objectForKey
:
@"radius"
]
doubleValue
];
NSArray
*
center
=
[
self
valueForTriggerOption
:
@"center"
];
double
radius
=
[[
self
valueForTriggerOption
:
@"radius"
]
doubleValue
];
CLLocationCoordinate2D
coord
=
CLLocationCoordinate2DMake
([
center
[
0
]
doubleValue
],
[
center
[
1
]
doubleValue
]);
...
...
@@ -449,8 +441,8 @@
radius
:
radius
identifier
:
self
.
identifier
];
region
.
notifyOnEntry
=
[[
dict
objectForKey
:
@"notifyOnEntry"
]
boolValue
];
region
.
notifyOnExit
=
[[
dict
objectForKey
:
@"notifyOnExit"
]
boolValue
];
region
.
notifyOnEntry
=
[[
self
valueForTriggerOption
:
@"notifyOnEntry"
]
boolValue
];
region
.
notifyOnExit
=
[[
self
valueForTriggerOption
:
@"notifyOnExit"
]
boolValue
];
return
[
UNLocationNotificationTrigger
triggerWithRegion
:
region
repeats
:
YES
];
}
...
...
@@ -472,7 +464,7 @@
*/
-
(
NSCalendarUnit
)
repeatInterval
{
NSString
*
interval
=
[
dict
objectForKey
:
@"every"
];
NSString
*
interval
=
[
self
valueForTriggerOption
:
@"every"
];
NSCalendarUnit
units
=
NSCalendarUnitYear
|
NSCalendarUnitMonth
|
NSCalendarUnitDay
|
NSCalendarUnitHour
|
NSCalendarUnitMinute
|
NSCalendarUnitSecond
;
if
([
interval
isEqualToString
:
@"minute"
])
...
...
@@ -504,7 +496,7 @@
-
(
NSDateComponents
*
)
customDateComponents
{
NSDateComponents
*
date
=
[[
NSDateComponents
alloc
]
init
];
NSDictionary
*
every
=
[
dict
objectForKey
:
@"every"
];
NSDictionary
*
every
=
[
self
valueForTriggerOption
:
@"every"
];
for
(
NSString
*
key
in
every
)
{
long
value
=
[[
every
valueForKey
:
key
]
longValue
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment