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
78308f18
Commit
78308f18
authored
Dec 01, 2013
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small iOS cleanup.
parent
a9d437df
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
41 deletions
+49
-41
APPLocalNotification.h
src/ios/APPLocalNotification.h
+2
-3
APPLocalNotification.m
src/ios/APPLocalNotification.m
+47
-38
No files found.
src/ios/APPLocalNotification.h
View file @
78308f18
/**
/**
* APPLocalNotification.h
* Cordova LocalNotification Plugin
* Cordova LocalNotification Plugin
*
*
* Created by Sebastian Katzer (github.com/katzer)
on 10/08/2013
.
* Created by Sebastian Katzer (github.com/katzer).
* Copyright 2013 Sebastian Katzer. All rights reserved.
* Copyright 2013 Sebastian Katzer. All rights reserved.
*
GPL v2
licensed
*
LGPL v2.1
licensed
*/
*/
#import <Foundation/Foundation.h>
#import <Foundation/Foundation.h>
...
...
src/ios/APPLocalNotification.m
View file @
78308f18
/**
/**
* APPLocalNotification.m
* Cordova LocalNotification Plugin
* Cordova LocalNotification Plugin
*
*
* Created by Sebastian Katzer (github.com/katzer)
on 10/08/2013
.
* Created by Sebastian Katzer (github.com/katzer).
* Copyright 2013 Sebastian Katzer. All rights reserved.
* Copyright 2013 Sebastian Katzer. All rights reserved.
*
GPL v2
licensed
*
LGPL v2.1
licensed
*/
*/
#import "APPLocalNotification.h"
#import "APPLocalNotification.h"
@interface
APPLocalNotification
(
Private
)
@interface
APPLocalNotification
(
Private
)
-
(
NSMutableDictionary
*
)
repeatDict
;
-
(
NSMutableDictionary
*
)
repeatDict
;
// Alle zusätzlichen Metadaten der Notification als Hash
-
(
NSDictionary
*
)
userDict
:(
NSMutableDictionary
*
)
options
;
-
(
NSDictionary
*
)
userDict
:(
NSMutableDictionary
*
)
options
;
-
(
UILocalNotification
*
)
prepareNotification
:(
NSMutableDictionary
*
)
options
;
// Erstellt die Notification und setzt deren Eigenschaften
-
(
void
)
didReceiveLocalNotification
:(
NSNotification
*
)
localNotification
;
-
(
UILocalNotification
*
)
notificationWithProperties
:(
NSMutableDictionary
*
)
options
;
// Ruft die JS-Callbacks auf, nachdem eine Notification eingegangen ist
-
(
void
)
didReceiveLocalNotification
:(
NSNotification
*
)
localNotification
;
@end
@end
...
@@ -25,16 +26,14 @@
...
@@ -25,16 +26,14 @@
/**
/**
* Fügt eine neue Notification-Eintrag hinzu.
* Fügt eine neue Notification-Eintrag hinzu.
*
*
* @param {NSMutableDictionary} options
* @param {NSMutableDictionary} options
Die Eigenschaften der Notification
*/
*/
-
(
void
)
add
:(
CDVInvokedUrlCommand
*
)
command
-
(
void
)
add
:(
CDVInvokedUrlCommand
*
)
command
{
{
[
self
.
commandDelegate
runInBackground
:
^
{
[
self
.
commandDelegate
runInBackground
:
^
{
NSArray
*
arguments
=
[
command
arguments
];
NSArray
*
arguments
=
[
command
arguments
];
NSMutableDictionary
*
options
=
[
arguments
objectAtIndex
:
0
];
NSMutableDictionary
*
options
=
[
arguments
objectAtIndex
:
0
];
UILocalNotification
*
notification
=
[
self
prepareNotification
:
options
];
UILocalNotification
*
notification
=
[
self
notificationWithProperties
:
options
];
notification
.
userInfo
=
[
self
userDict
:
options
];
[[
UIApplication
sharedApplication
]
scheduleLocalNotification
:
notification
];
[[
UIApplication
sharedApplication
]
scheduleLocalNotification
:
notification
];
}];
}];
...
@@ -47,9 +46,9 @@
...
@@ -47,9 +46,9 @@
*/
*/
-
(
void
)
cancel
:(
CDVInvokedUrlCommand
*
)
command
-
(
void
)
cancel
:(
CDVInvokedUrlCommand
*
)
command
{
{
NSArray
*
arguments
=
[
command
arguments
];
NSArray
*
arguments
=
[
command
arguments
];
NSString
*
notificationId
=
[
arguments
objectAtIndex
:
0
];
NSString
*
notificationId
=
[
arguments
objectAtIndex
:
0
];
NSArray
*
notifications
=
[[
UIApplication
sharedApplication
]
scheduledLocalNotifications
];
NSArray
*
notifications
=
[[
UIApplication
sharedApplication
]
scheduledLocalNotifications
];
for
(
UILocalNotification
*
notification
in
notifications
)
for
(
UILocalNotification
*
notification
in
notifications
)
{
{
...
@@ -75,7 +74,7 @@
...
@@ -75,7 +74,7 @@
*/
*/
-
(
NSMutableDictionary
*
)
repeatDict
-
(
NSMutableDictionary
*
)
repeatDict
{
{
NSMutableDictionary
*
repeatDict
=
[[
NSMutableDictionary
alloc
]
init
];
NSMutableDictionary
*
repeatDict
=
[[
NSMutableDictionary
alloc
]
init
];
[
repeatDict
setObject
:[
NSNumber
numberWithInt
:
NSDayCalendarUnit
]
forKey
:
@"daily"
];
[
repeatDict
setObject
:[
NSNumber
numberWithInt
:
NSDayCalendarUnit
]
forKey
:
@"daily"
];
[
repeatDict
setObject
:[
NSNumber
numberWithInt
:
NSWeekCalendarUnit
]
forKey
:
@"weekly"
];
[
repeatDict
setObject
:[
NSNumber
numberWithInt
:
NSWeekCalendarUnit
]
forKey
:
@"weekly"
];
...
@@ -87,7 +86,7 @@
...
@@ -87,7 +86,7 @@
}
}
/**
/**
*
@private
*
Alle zusätzlichen Metadaten der Notification als Hash.
*/
*/
-
(
NSDictionary
*
)
userDict
:
(
NSMutableDictionary
*
)
options
-
(
NSDictionary
*
)
userDict
:
(
NSMutableDictionary
*
)
options
{
{
...
@@ -99,10 +98,9 @@
...
@@ -99,10 +98,9 @@
}
}
/**
/**
* @private
* Erstellt die Notification und setzt deren Eigenschaften.
* Erstellt die Notification und setzt deren Eigenschaften.
*/
*/
-
(
UILocalNotification
*
)
prepareNotification
:
(
NSMutableDictionary
*
)
options
-
(
UILocalNotification
*
)
notificationWithProperties
:
(
NSMutableDictionary
*
)
options
{
{
UILocalNotification
*
notification
=
[[
UILocalNotification
alloc
]
init
];
UILocalNotification
*
notification
=
[[
UILocalNotification
alloc
]
init
];
...
@@ -111,53 +109,64 @@
...
@@ -111,53 +109,64 @@
NSString
*
title
=
[
options
objectForKey
:
@"title"
];
NSString
*
title
=
[
options
objectForKey
:
@"title"
];
NSString
*
sound
=
[
options
objectForKey
:
@"sound"
];
NSString
*
sound
=
[
options
objectForKey
:
@"sound"
];
NSString
*
repeat
=
[
options
objectForKey
:
@"repeat"
];
NSString
*
repeat
=
[
options
objectForKey
:
@"repeat"
];
bool
hasAction
=
([[
options
objectForKey
:
@"hasAction"
]
intValue
]
==
1
)?
YES
:
NO
;
NSInteger
badge
=
[[
options
objectForKey
:
@"badge"
]
intValue
];
NSInteger
badge
=
[[
options
objectForKey
:
@"badge"
]
intValue
];
NSDate
*
date
=
[
NSDate
dateWithTimeIntervalSince1970
:
timestamp
];
notification
.
fireDate
=
date
;
notification
.
fireDate
=
[
NSDate
dateWithTimeIntervalSince1970
:
timestamp
]
;
notification
.
timeZone
=
[
NSTimeZone
defaultTimeZone
];
notification
.
timeZone
=
[
NSTimeZone
defaultTimeZone
];
notification
.
repeatInterval
=
[[[
self
repeatDict
]
objectForKey
:
repeat
]
intValue
];
notification
.
repeatInterval
=
[[[
self
repeatDict
]
objectForKey
:
repeat
]
intValue
];
notification
.
userInfo
=
[
self
userDict
:
options
];
notification
.
applicationIconBadgeNumber
=
badge
;
if
(
!
[
msg
isEqualToString
:
@""
])
if
(
!
[
msg
isEqualToString
:
@""
])
{
{
notification
.
alertBody
=
title
?
[
NSString
stringWithFormat
:
@"%@
\n
%@"
,
title
,
msg
]
:
msg
;
if
(
title
)
{
notification
.
alertBody
=
[
NSString
stringWithFormat
:
@"%@
\n
%@"
,
title
,
msg
];
}
else
{
notification
.
alertBody
=
msg
;
}
}
}
if
(
sound
!=
(
NSString
*
)
[
NSNull
null
])
if
(
sound
!=
(
NSString
*
)
[
NSNull
null
])
{
{
notification
.
soundName
=
[
sound
isEqualToString
:
@""
]
?
UILocalNotificationDefaultSoundName
:
sound
;
if
([
sound
isEqualToString
:
@""
])
{
notification
.
soundName
=
UILocalNotificationDefaultSoundName
;
}
else
{
notification
.
soundName
=
sound
;
}
}
}
notification
.
hasAction
=
hasAction
;
notification
.
applicationIconBadgeNumber
=
badge
;
return
notification
;
return
notification
;
}
}
/**
/**
* @private
* Ruft die JS-Callbacks auf, nachdem eine Notification eingegangen ist.
* Ruft die JS-Callbacks auf, nachdem eine Notification eingegangen ist.
*/
*/
-
(
void
)
didReceiveLocalNotification
:
(
NSNotification
*
)
localNotification
-
(
void
)
didReceiveLocalNotification
:
(
NSNotification
*
)
localNotification
{
{
UILocalNotification
*
notification
=
[
localNotification
object
];
UIApplicationState
state
=
[[
UIApplication
sharedApplication
]
applicationState
];
UIApplicationState
state
=
[[
UIApplication
sharedApplication
]
applicationState
];
bool
isActive
=
state
==
UIApplicationStateActive
;
bool
isActive
=
state
==
UIApplicationStateActive
;
NSString
*
id
=
[
notification
.
userInfo
objectForKey
:
@"id"
];
UILocalNotification
*
notification
=
[
localNotification
object
];
NSString
*
callbackFn
=
[
notification
.
userInfo
objectForKey
:
isActive
?
@"foreground"
:
@"background"
];
NSString
*
id
=
[
notification
.
userInfo
objectForKey
:
@"id"
];
NSString
*
callbackType
=
isActive
?
@"foreground"
:
@"background"
;
NSString
*
callbackFn
=
[
notification
.
userInfo
objectForKey
:
callbackType
];
if
(
callbackFn
.
length
>
0
)
if
(
callbackFn
.
length
>
0
)
{
{
NSString
*
jsCallB
ack
=
[
NSString
stringWithFormat
:
@"setTimeout('%@(%@)',0)"
,
callbackFn
,
id
];
NSString
*
callb
ack
=
[
NSString
stringWithFormat
:
@"setTimeout('%@(%@)',0)"
,
callbackFn
,
id
];
[
self
writeJavascript
:
jsCallB
ack
];
[
self
writeJavascript
:
callb
ack
];
}
}
}
}
/**
/**
* @private
* Registriert den Observer für LocalNotification Events.
* Registriert den Observer für LocalNotification Events.
*/
*/
-
(
void
)
pluginInitialize
-
(
void
)
pluginInitialize
...
...
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