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
16a1b765
Commit
16a1b765
authored
Aug 11, 2013
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JS Callbacks werden aufgerufen
parent
6bee7c55
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
9 deletions
+42
-9
APPLocalNotification.m
src/ios/APPLocalNotification.m
+42
-9
No files found.
src/ios/APPLocalNotification.m
View file @
16a1b765
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
-
(
NSDictionary
*
)
userDict
:(
NSMutableDictionary
*
)
options
;
-
(
NSDictionary
*
)
userDict
:(
NSMutableDictionary
*
)
options
;
-
(
UILocalNotification
*
)
prepareNotification
:(
NSMutableDictionary
*
)
options
;
-
(
UILocalNotification
*
)
prepareNotification
:(
NSMutableDictionary
*
)
options
;
-
(
void
)
aWindowBecameMain
:(
NSNotification
*
)
notification
;
@end
@end
...
@@ -48,10 +50,12 @@
...
@@ -48,10 +50,12 @@
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
)
{
NSString
*
notId
=
[
notification
.
userInfo
objectForKey
:
@"notificationId"
];
NSString
*
notId
=
[
notification
.
userInfo
objectForKey
:
@"notificationId"
];
if
([
notificationId
isEqualToString
:
notId
])
{
if
([
notificationId
isEqualToString
:
notId
])
{
[[
UIApplication
sharedApplication
]
cancelLocalNotification
:
notification
];
[[
UIApplication
sharedApplication
]
cancelLocalNotification
:
notification
];
}
}
}
}
...
@@ -86,13 +90,11 @@
...
@@ -86,13 +90,11 @@
*/
*/
-
(
NSDictionary
*
)
userDict
:
(
NSMutableDictionary
*
)
options
-
(
NSDictionary
*
)
userDict
:
(
NSMutableDictionary
*
)
options
{
{
NSString
*
notificationId
=
[
options
objectForKey
:
@"id"
];
NSString
*
id
=
[
options
objectForKey
:
@"id"
];
NSString
*
bg
=
[
options
objectForKey
:
@"background"
];
NSString
*
bg
=
[
options
objectForKey
:
@"background"
];
NSString
*
fg
=
[
options
objectForKey
:
@"foreground"
];
NSString
*
fg
=
[
options
objectForKey
:
@"foreground"
];
NSDictionary
*
userDict
=
[
NSDictionary
dictionaryWithObjectsAndKeys
:
notificationId
,
@"notificationId"
,
bg
,
@"background"
,
fg
,
@"foreground"
,
nil
];
return
userDict
;
return
[
NSDictionary
dictionaryWithObjectsAndKeys
:
id
,
@"id"
,
bg
,
@"background"
,
fg
,
@"foreground"
,
nil
]
;
}
}
/**
/**
...
@@ -115,7 +117,7 @@
...
@@ -115,7 +117,7 @@
notification
.
hasAction
=
hasAction
;
notification
.
hasAction
=
hasAction
;
notification
.
timeZone
=
[
NSTimeZone
defaultTimeZone
];
notification
.
timeZone
=
[
NSTimeZone
defaultTimeZone
];
notification
.
repeatInterval
=
[[[
self
repeatDict
]
objectForKey
:
repeat
]
intValue
];
notification
.
repeatInterval
=
[[[
self
repeatDict
]
objectForKey
:
repeat
]
intValue
];
notification
.
alertBody
=
([
msg
isEqualToString
:
@""
])
?
nil
:
msg
;
notification
.
alertBody
=
([
msg
isEqualToString
:
@""
])
?
nil
:
msg
;
notification
.
alertAction
=
action
;
notification
.
alertAction
=
action
;
notification
.
soundName
=
sound
;
notification
.
soundName
=
sound
;
notification
.
applicationIconBadgeNumber
=
badge
;
notification
.
applicationIconBadgeNumber
=
badge
;
...
@@ -123,4 +125,34 @@
...
@@ -123,4 +125,34 @@
return
notification
;
return
notification
;
}
}
/**
* @private
* Ruft die JS-Callbacks auf, nachdem eine Notification eingegangen ist.
*/
-
(
void
)
didReceiveLocalNotification
:
(
NSNotification
*
)
localNotification
{
UILocalNotification
*
notification
=
[
localNotification
object
];
UIApplicationState
state
=
[[
UIApplication
sharedApplication
]
applicationState
];
bool
isActive
=
state
==
UIApplicationStateActive
;
NSString
*
id
=
[
notification
.
userInfo
objectForKey
:
@"id"
];
NSString
*
callbackFn
=
[
notification
.
userInfo
objectForKey
:
isActive
?
@"foreground"
:
@"background"
];
if
(
callbackFn
.
length
>
0
)
{
NSString
*
jsCallBack
=
[
NSString
stringWithFormat
:
@"%@(%@)"
,
callbackFn
,
id
];
[
self
writeJavascript
:
jsCallBack
];
}
}
/**
* @private
* Registriert den Observer für LocalNotification Events.
*/
-
(
void
)
pluginInitialize
{
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
didReceiveLocalNotification
:
)
name
:
CDVLocalNotification
object
:
nil
];
}
@end
@end
\ No newline at end of file
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