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
492924ed
Commit
492924ed
authored
Jul 04, 2017
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support for location based trigger
parent
ba07d4ce
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
13 deletions
+56
-13
plugin.xml
plugin.xml
+1
-0
APPNotificationOptions.m
src/ios/APPNotificationOptions.m
+51
-12
local-notification-util.js
www/local-notification-util.js
+4
-1
No files found.
plugin.xml
View file @
492924ed
...
...
@@ -54,6 +54,7 @@
</config-file>
<framework
src=
"UserNotifications.framework"
/>
<framework
src=
"CoreLocation.framework"
/>
<header-file
src=
"src/ios/APPLocalNotification.h"
/>
<source-file
src=
"src/ios/APPLocalNotification.m"
/>
...
...
src/ios/APPNotificationOptions.m
View file @
492924ed
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
*
* @APPPLANT_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
...
...
@@ -17,13 +13,12 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
#import "APPNotificationOptions.h"
#import "UNUserNotificationCenter+APPLocalNotification.h"
@import
CoreLocation
;
@import
UserNotifications
;
@interface
APPNotificationOptions
()
...
...
@@ -62,6 +57,18 @@
#pragma mark Properties
/**
* The type for the notification.
*
* @return [ NSString* ]
*/
-
(
NSString
*
)
type
{
NSString
*
type
=
[
dict
objectForKey
:
@"type"
];
return
type
.
length
?
type
:
@"normal"
;
}
/**
* The ID for the notification.
*
* @return [ NSNumber* ]
...
...
@@ -269,6 +276,14 @@
*/
-
(
UNNotificationTrigger
*
)
trigger
{
NSString
*
type
=
[
self
type
];
if
([
type
isEqualToString
:
@"location"
])
return
[
self
triggerWithRegion
];
if
(
!
[
type
isEqualToString
:
@"normal"
])
NSLog
(
@"Unknown type: %@"
,
type
);
if
([
self
isRepeating
])
return
[
self
repeatingTrigger
];
...
...
@@ -348,12 +363,12 @@
id
every
=
[
dict
objectForKey
:
@"every"
];
if
([
every
isKindOfClass
:
NSString
.
class
])
return
[
self
repeatingT
riggerWithDateMatchingComponents
];
return
[
self
t
riggerWithDateMatchingComponents
];
if
([
every
isKindOfClass
:
NSDictionary
.
class
])
return
[
self
repeatingT
riggerWithCustomDateMatchingComponents
];
return
[
self
t
riggerWithCustomDateMatchingComponents
];
return
[
self
repeatingT
riggerWithTimeInterval
];
return
[
self
t
riggerWithTimeInterval
];
}
/**
...
...
@@ -361,7 +376,7 @@
*
* @return [ UNTimeIntervalNotificationTrigger* ]
*/
-
(
UNTimeIntervalNotificationTrigger
*
)
repeatingT
riggerWithTimeInterval
-
(
UNTimeIntervalNotificationTrigger
*
)
t
riggerWithTimeInterval
{
long
interval
=
[[
dict
objectForKey
:
@"every"
]
longValue
];
...
...
@@ -379,7 +394,7 @@
*
* @return [ UNCalendarNotificationTrigger* ]
*/
-
(
UNCalendarNotificationTrigger
*
)
repeatingT
riggerWithDateMatchingComponents
-
(
UNCalendarNotificationTrigger
*
)
t
riggerWithDateMatchingComponents
{
NSCalendar
*
cal
=
[[
NSCalendar
alloc
]
initWithCalendarIdentifier
:
NSCalendarIdentifierGregorian
];
...
...
@@ -398,7 +413,7 @@
*
* @return [ UNCalendarNotificationTrigger* ]
*/
-
(
UNCalendarNotificationTrigger
*
)
repeatingT
riggerWithCustomDateMatchingComponents
-
(
UNCalendarNotificationTrigger
*
)
t
riggerWithCustomDateMatchingComponents
{
NSCalendar
*
cal
=
[[
NSCalendar
alloc
]
initWithCalendarIdentifier
:
NSCalendarIdentifierGregorian
];
...
...
@@ -413,6 +428,30 @@
}
/**
* A repeating trigger based on a location region.
*
* @return [ UNLocationNotificationTrigger* ]
*/
-
(
UNLocationNotificationTrigger
*
)
triggerWithRegion
{
NSArray
*
center
=
[
dict
objectForKey
:
@"center"
];
double
radius
=
[[
dict
objectForKey
:
@"radius"
]
doubleValue
];
CLLocationCoordinate2D
coord
=
CLLocationCoordinate2DMake
([
center
[
0
]
doubleValue
],
[
center
[
1
]
doubleValue
]);
CLCircularRegion
*
region
=
[[
CLCircularRegion
alloc
]
initWithCenter
:
coord
radius
:
radius
identifier
:
self
.
identifier
];
region
.
notifyOnEntry
=
[[
dict
objectForKey
:
@"notifyOnEntry"
]
boolValue
];
region
.
notifyOnExit
=
[[
dict
objectForKey
:
@"notifyOnExit"
]
boolValue
];
return
[
UNLocationNotificationTrigger
triggerWithRegion
:
region
repeats
:
YES
];
}
/**
* The time interval between the next fire date and now.
*
* @return [ double ]
...
...
www/local-notification-util.js
View file @
492924ed
...
...
@@ -21,6 +21,7 @@ var exec = require('cordova/exec'),
// Default values
exports
.
_defaults
=
{
id
:
0
,
type
:
'normal'
,
text
:
''
,
title
:
''
,
sound
:
'res://platform_default'
,
...
...
@@ -54,6 +55,8 @@ exports.applyPlatformSpecificOptions = function () {
break
;
case
'iOS'
:
defaults
.
attachments
=
undefined
;
defaults
.
region
=
undefined
;
defaults
.
radius
=
undefined
;
break
;
}
};
...
...
@@ -307,7 +310,7 @@ channel.deviceready.subscribe(function () {
// Called before 'deviceready' event
channel
.
onCordovaReady
.
subscribe
(
function
()
{
// S
tore launchedBy notification
// S
et launchDetails object
exports
.
exec
(
'launchDetails'
);
// Device plugin is ready now
channel
.
onCordovaInfoReady
.
subscribe
(
function
()
{
...
...
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