Commit ebee0373 by Sebastián Katzer

Renamed internal classes

parent cac11bc1
...@@ -59,15 +59,15 @@ ...@@ -59,15 +59,15 @@
<header-file src="src/ios/APPLocalNotification.h" /> <header-file src="src/ios/APPLocalNotification.h" />
<source-file src="src/ios/APPLocalNotification.m" /> <source-file src="src/ios/APPLocalNotification.m" />
<header-file src="src/ios/APPLocalNotificationOptions.h" /> <header-file src="src/ios/APPNotificationContent.h" />
<source-file src="src/ios/APPLocalNotificationOptions.m" /> <source-file src="src/ios/APPNotificationContent.m" />
<header-file src="src/ios/APPNotificationOptions.h" />
<source-file src="src/ios/APPNotificationOptions.m" />
<header-file src="src/ios/UNUserNotificationCenter+APPLocalNotification.h" /> <header-file src="src/ios/UNUserNotificationCenter+APPLocalNotification.h" />
<source-file src="src/ios/UNUserNotificationCenter+APPLocalNotification.m" /> <source-file src="src/ios/UNUserNotificationCenter+APPLocalNotification.m" />
<header-file src="src/ios/UNMutableNotificationContent+APPLocalNotification.h" />
<source-file src="src/ios/UNMutableNotificationContent+APPLocalNotification.m" />
<header-file src="src/ios/UNNotificationRequest+APPLocalNotification.h" /> <header-file src="src/ios/UNNotificationRequest+APPLocalNotification.h" />
<source-file src="src/ios/UNNotificationRequest+APPLocalNotification.m" /> <source-file src="src/ios/UNNotificationRequest+APPLocalNotification.m" />
......
...@@ -22,10 +22,10 @@ ...@@ -22,10 +22,10 @@
*/ */
#import "APPLocalNotification.h" #import "APPLocalNotification.h"
#import "APPLocalNotificationOptions.h" #import "APPNotificationOptions.h"
#import "UNUserNotificationCenter+APPLocalNotification.h" #import "UNUserNotificationCenter+APPLocalNotification.h"
#import "UNNotificationRequest+APPLocalNotification.h" #import "UNNotificationRequest+APPLocalNotification.h"
#import "UNMutableNotificationContent+APPLocalNotification.h" #import "APPNotificationContent.h"
@interface APPLocalNotification () @interface APPLocalNotification ()
...@@ -72,9 +72,9 @@ ...@@ -72,9 +72,9 @@
[self.commandDelegate runInBackground:^{ [self.commandDelegate runInBackground:^{
for (NSDictionary* options in notifications) { for (NSDictionary* options in notifications) {
UNMutableNotificationContent* notification; APPNotificationContent* notification;
notification = [[UNMutableNotificationContent alloc] notification = [[APPNotificationContent alloc]
initWithOptions:options]; initWithOptions:options];
[self scheduleNotification:notification]; [self scheduleNotification:notification];
...@@ -547,7 +547,7 @@ ...@@ -547,7 +547,7 @@
/** /**
* Schedule the local notification. * Schedule the local notification.
*/ */
- (void) scheduleNotification:(UNMutableNotificationContent*)notification - (void) scheduleNotification:(APPNotificationContent*)notification
{ {
__weak APPLocalNotification* weakSelf = self; __weak APPLocalNotification* weakSelf = self;
UNNotificationRequest* request = notification.request; UNNotificationRequest* request = notification.request;
...@@ -563,7 +563,7 @@ ...@@ -563,7 +563,7 @@
// */ // */
//- (void) updateNotification:(UILocalNotification*)notification //- (void) updateNotification:(UILocalNotification*)notification
// withOptions:(NSDictionary*)newOptions // withOptions:(NSDictionary*)newOptions
//{ //{APPNotificationRequest*
// NSMutableDictionary* options = [notification.userInfo mutableCopy]; // NSMutableDictionary* options = [notification.userInfo mutableCopy];
// //
// [options addEntriesFromDictionary:newOptions]; // [options addEntriesFromDictionary:newOptions];
...@@ -686,6 +686,10 @@ ...@@ -686,6 +686,10 @@
/** /**
* Fire general event. * Fire general event.
*
* @param [ NSString* ] event The name of the event to fire.
*
* @return [ Void ]
*/ */
- (void) fireEvent:(NSString*)event - (void) fireEvent:(NSString*)event
{ {
...@@ -693,17 +697,22 @@ ...@@ -693,17 +697,22 @@
} }
/** /**
* Fire event for local notification. * Fire event for about a local notification.
*
* @param [ NSString* ] event The name of the event to fire.
* @param [ APPNotificationRequest* ] notification The local notification.
*
* @return [ Void ]
*/ */
- (void) fireEvent:(NSString*)event - (void) fireEvent:(NSString*)event
notification:(UNNotificationRequest*)notification notification:(UNNotificationRequest*)request
{ {
NSString* js; NSString* js;
NSString* appState = [self applicationState]; NSString* appState = [self applicationState];
NSString* params = [NSString stringWithFormat:@"\"%@\"", appState]; NSString* params = [NSString stringWithFormat:@"\"%@\"", appState];
if (notification) { if (request) {
NSString* args = [notification encodeToJSON]; NSString* args = [request encodeToJSON];
params = [NSString stringWithFormat:@"%@,'%@'", args, appState]; params = [NSString stringWithFormat:@"%@,'%@'", args, appState];
} }
......
...@@ -21,15 +21,14 @@ ...@@ -21,15 +21,14 @@
* @APPPLANT_LICENSE_HEADER_END@ * @APPPLANT_LICENSE_HEADER_END@
*/ */
#import "APPLocalNotificationOptions.h" #import "APPNotificationOptions.h"
@import UserNotifications; @import UserNotifications;
@interface UNMutableNotificationContent (APPLocalNotification) @interface APPNotificationContent : UNMutableNotificationContent
- (id) initWithOptions:(NSDictionary*)dict; - (id) initWithOptions:(NSDictionary*)dict;
- (APPLocalNotificationOptions*) options; - (APPNotificationOptions*) options;
- (UNNotificationRequest*) request; - (UNNotificationRequest*) request;
- (NSString*) encodeToJSON;
@end @end
...@@ -21,15 +21,15 @@ ...@@ -21,15 +21,15 @@
* @APPPLANT_LICENSE_HEADER_END@ * @APPPLANT_LICENSE_HEADER_END@
*/ */
#import "UNMutableNotificationContent+APPLocalNotification.h" #import "APPNotificationContent.h"
#import "APPLocalNotificationOptions.h" #import "APPNotificationOptions.h"
#import <objc/runtime.h> #import <objc/runtime.h>
@import UserNotifications; @import UserNotifications;
static char optionsKey; static char optionsKey;
@implementation UNMutableNotificationContent (APPLocalNotification) @implementation APPNotificationContent : UNMutableNotificationContent
#pragma mark - #pragma mark -
#pragma mark Init #pragma mark Init
...@@ -58,7 +58,7 @@ static char optionsKey; ...@@ -58,7 +58,7 @@ static char optionsKey;
*/ */
- (void) __init - (void) __init
{ {
APPLocalNotificationOptions* options = self.options; APPNotificationOptions* options = self.options;
self.title = options.title; self.title = options.title;
self.subtitle = options.subtitle; self.subtitle = options.subtitle;
...@@ -73,14 +73,14 @@ static char optionsKey; ...@@ -73,14 +73,14 @@ static char optionsKey;
/** /**
* The options used to initialize the notification. * The options used to initialize the notification.
* *
* @return [ APPLocalNotificationOptions* ] options * @return [ APPNotificationOptions* ] options
*/ */
- (APPLocalNotificationOptions*) options - (APPNotificationOptions*) options
{ {
APPLocalNotificationOptions* options = [self getOptions]; APPNotificationOptions* options = [self getOptions];
if (!options) { if (!options) {
options = [[APPLocalNotificationOptions alloc] options = [[APPNotificationOptions alloc]
initWithDict:[self userInfo]]; initWithDict:[self userInfo]];
[self setOptions:options]; [self setOptions:options];
...@@ -97,49 +97,22 @@ static char optionsKey; ...@@ -97,49 +97,22 @@ static char optionsKey;
*/ */
- (UNNotificationRequest*) request - (UNNotificationRequest*) request
{ {
APPLocalNotificationOptions* opts = [self getOptions]; APPNotificationOptions* opts = [self getOptions];
return [UNNotificationRequest requestWithIdentifier:opts.identifier return [UNNotificationRequest requestWithIdentifier:opts.identifier
content:self content:self
trigger:opts.trigger]; trigger:opts.trigger];
} }
/**
* Encode the user info dict to JSON.
*
* @return [ NSString* ]
*/
- (NSString*) encodeToJSON
{
NSString* json;
NSData* data;
NSMutableDictionary* obj = [self.userInfo mutableCopy];
[obj removeObjectForKey:@"updatedAt"];
if (obj == NULL || obj.count == 0)
return json;
data = [NSJSONSerialization dataWithJSONObject:obj
options:NSJSONWritingPrettyPrinted
error:NULL];
json = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
return [json stringByReplacingOccurrencesOfString:@"\n"
withString:@""];
}
#pragma mark - #pragma mark -
#pragma mark Private #pragma mark Private
/** /**
* The options used to initialize the notification. * The options used to initialize the notification.
* *
* @return [ APPLocalNotificationOptions* ] * @return [ APPNotificationOptions* ]
*/ */
- (APPLocalNotificationOptions*) getOptions - (APPNotificationOptions*) getOptions
{ {
return objc_getAssociatedObject(self, &optionsKey); return objc_getAssociatedObject(self, &optionsKey);
} }
...@@ -151,7 +124,7 @@ static char optionsKey; ...@@ -151,7 +124,7 @@ static char optionsKey;
* *
* @return [ Void ] * @return [ Void ]
*/ */
- (void) setOptions:(APPLocalNotificationOptions*)options - (void) setOptions:(APPNotificationOptions*)options
{ {
objc_setAssociatedObject(self, &optionsKey, objc_setAssociatedObject(self, &optionsKey,
options, OBJC_ASSOCIATION_RETAIN_NONATOMIC); options, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
@import UserNotifications; @import UserNotifications;
@interface APPLocalNotificationOptions : NSObject @interface APPNotificationOptions : NSObject
@property (readonly, getter=id) NSNumber* id; @property (readonly, getter=id) NSNumber* id;
@property (readonly, getter=identifier) NSString* identifier; @property (readonly, getter=identifier) NSString* identifier;
......
...@@ -21,18 +21,18 @@ ...@@ -21,18 +21,18 @@
* @APPPLANT_LICENSE_HEADER_END@ * @APPPLANT_LICENSE_HEADER_END@
*/ */
#import "APPLocalNotificationOptions.h" #import "APPNotificationOptions.h"
@import UserNotifications; @import UserNotifications;
@interface APPLocalNotificationOptions () @interface APPNotificationOptions ()
// The dictionary which contains all notification properties // The dictionary which contains all notification properties
@property(nonatomic, retain) NSDictionary* dict; @property(nonatomic, retain) NSDictionary* dict;
@end @end
@implementation APPLocalNotificationOptions @implementation APPNotificationOptions : NSObject
@synthesize dict; @synthesize dict;
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
* *
* @param [ NSDictionary* ] dict A key-value property map. * @param [ NSDictionary* ] dict A key-value property map.
* *
* @return [ APPLocalNotificationOptions ] * @return [ APPNotificationOptions ]
*/ */
- (id) initWithDict:(NSDictionary*)dictionary - (id) initWithDict:(NSDictionary*)dictionary
{ {
......
...@@ -21,14 +21,14 @@ ...@@ -21,14 +21,14 @@
* @APPPLANT_LICENSE_HEADER_END@ * @APPPLANT_LICENSE_HEADER_END@
*/ */
#import "APPLocalNotificationOptions.h" #import "APPNotificationOptions.h"
@import UserNotifications; @import UserNotifications;
@interface UNNotificationRequest (APPLocalNotification) @interface UNNotificationRequest (APPLocalNotification)
// The options provided by the plug-in // The options provided by the plug-in
- (APPLocalNotificationOptions*) options; - (APPNotificationOptions*) options;
// Encode the user info dict to JSON // Encode the user info dict to JSON
- (NSString*) encodeToJSON; - (NSString*) encodeToJSON;
......
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
* @APPPLANT_LICENSE_HEADER_END@ * @APPPLANT_LICENSE_HEADER_END@
*/ */
#import "APPLocalNotificationOptions.h" #import "APPNotificationOptions.h"
#import "UNNotificationRequest+APPLocalNotification.h" #import "UNNotificationRequest+APPLocalNotification.h"
#import "UNMutableNotificationContent+APPLocalNotification.h" #import "APPNotificationContent.h"
#import <objc/runtime.h> #import <objc/runtime.h>
@import UserNotifications; @import UserNotifications;
...@@ -35,7 +35,7 @@ static char optionsKey; ...@@ -35,7 +35,7 @@ static char optionsKey;
/** /**
* Get associated option object * Get associated option object
*/ */
- (APPLocalNotificationOptions*) getOptions - (APPNotificationOptions*) getOptions
{ {
return objc_getAssociatedObject(self, &optionsKey); return objc_getAssociatedObject(self, &optionsKey);
} }
...@@ -43,7 +43,7 @@ static char optionsKey; ...@@ -43,7 +43,7 @@ static char optionsKey;
/** /**
* Set associated option object * Set associated option object
*/ */
- (void) setOptions:(APPLocalNotificationOptions*)options - (void) setOptions:(APPNotificationOptions*)options
{ {
objc_setAssociatedObject(self, &optionsKey, objc_setAssociatedObject(self, &optionsKey,
options, OBJC_ASSOCIATION_RETAIN_NONATOMIC); options, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
...@@ -52,12 +52,12 @@ static char optionsKey; ...@@ -52,12 +52,12 @@ static char optionsKey;
/** /**
* The options provided by the plug-in. * The options provided by the plug-in.
*/ */
- (APPLocalNotificationOptions*) options - (APPNotificationOptions*) options
{ {
APPLocalNotificationOptions* options = [self getOptions]; APPNotificationOptions* options = [self getOptions];
if (!options) { if (!options) {
options = [[APPLocalNotificationOptions alloc] options = [[APPNotificationOptions alloc]
initWithDict:[self.content userInfo]]; initWithDict:[self.content userInfo]];
[self setOptions:options]; [self setOptions:options];
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* @APPPLANT_LICENSE_HEADER_END@ * @APPPLANT_LICENSE_HEADER_END@
*/ */
#import "UNMutableNotificationContent+APPLocalNotification.h" #import "APPNotificationContent.h"
@interface UNUserNotificationCenter (APPLocalNotification) @interface UNUserNotificationCenter (APPLocalNotification)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment