Ignite Tools
Shared/Airship/Library/PushLib/UAPush.h
00001 /*
00002  Copyright 2009-2011 Urban Airship Inc. All rights reserved.
00003 
00004  Redistribution and use in source and binary forms, with or without
00005  modification, are permitted provided that the following conditions are met:
00006 
00007  1. Redistributions of source code must retain the above copyright notice, this
00008  list of conditions and the following disclaimer.
00009 
00010  2. Redistributions in binaryform must reproduce the above copyright notice,
00011  this list of conditions and the following disclaimer in the documentation
00012  and/or other materials provided withthe distribution.
00013 
00014  THIS SOFTWARE IS PROVIDED BY THE URBAN AIRSHIP INC``AS IS'' AND ANY EXPRESS OR
00015  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00016  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
00017  EVENT SHALL URBAN AIRSHIP INC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
00018  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00019  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00020  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00021  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
00022  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00023  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00024  */
00025 
00026 #import "UAGlobal.h"
00027 #import "UAirship.h"
00028 #import "UAObservable.h"
00029 
00030 #define kEnabled @"UAPushEnabled"
00031 #define kAlias @"UAPushAlias"
00032 #define kTags @"UAPushTags"
00033 #define kBadge @"UAPushBadge"
00034 #define kQuietTime @"UAPushQuietTime"
00035 #define kTimeZone @"UAPushTimeZone"
00036 
00037 #define PUSH_UI_CLASS @"UAPushUI"
00038 #define PUSH_DELEGATE_CLASS @"UAPushNotificationHandler"
00039 
00040 UA_VERSION_INTERFACE(UAPushVersion)
00041 
00042 
00046 @protocol UAPushUIProtocol
00047 + (void)openApnsSettings:(UIViewController *)viewController
00048                    animated:(BOOL)animated;
00049 + (void)openTokenSettings:(UIViewController *)viewController //TODO: remove from lib - it's a demo feature
00050                    animated:(BOOL)animated;
00051 + (void)closeApnsSettingsAnimated:(BOOL)animated;
00052 + (void)closeTokenSettingsAnimated:(BOOL)animated;//TODO: remove from lib - it's a demo feature
00053 @end
00054 
00059 @protocol UAPushNotificationDelegate
00060 - (void)displayNotificationAlert:(NSString *)alertMessage;
00061 - (void)displayLocalizedNotificationAlert:(NSDictionary *)alertDict;
00062 - (void)playNotificationSound:(NSString *)sound;
00063 - (void)handleCustomPayload:(NSDictionary *)notification :(NSDictionary *)customPayload;
00064 - (void)handleBadgeUpdate:(int)badgeNumber;
00065 - (void)handleBackgroundNotification:(NSDictionary *)notification;
00066 @end
00067 
00068 
00072 @interface UAPush : UAObservable<UARegistrationObserver> {
00073     
00074     id<UAPushNotificationDelegate> delegate; 
00075     NSObject<UAPushNotificationDelegate> *defaultPushHandler; 
00077   @private
00078     BOOL pushEnabled; 
00079     BOOL autobadgeEnabled;
00080     UIRemoteNotificationType notificationTypes; 
00081     NSString *alias; 
00082     NSMutableArray *tags; 
00083     NSMutableDictionary *quietTime; 
00084     NSString *tz; 
00085 }
00086 
00087 @property (nonatomic, assign) id<UAPushNotificationDelegate> delegate;
00088 @property (nonatomic, assign) BOOL pushEnabled;
00089 @property (nonatomic, retain) NSString *alias;
00090 @property (nonatomic, retain) NSMutableArray *tags;
00091 @property (nonatomic, retain) NSMutableDictionary *quietTime;
00092 @property (nonatomic, retain) NSString *tz;
00093 @property (nonatomic, readonly) UIRemoteNotificationType notificationTypes;
00094 
00095 SINGLETON_INTERFACE(UAPush);
00096 
00107 + (void)useCustomUI:(Class)customUIClass;
00108 + (void)openApnsSettings:(UIViewController *)viewController
00109                 animated:(BOOL)animated;
00110 + (void)openTokenSettings:(UIViewController *)viewController
00111                  animated:(BOOL)animated;
00112 + (void)closeApnsSettingsAnimated:(BOOL)animated;
00113 + (void)closeTokenSettingsAnimated:(BOOL)animated;
00114 
00115 - (void)registerForRemoteNotificationTypes:(UIRemoteNotificationType)types;
00116 - (void)registerDeviceToken:(NSData *)token;
00117 - (void)updateRegistration;
00118 
00119 // Change tags for current device token
00120 - (void)addTagToCurrentDevice:(NSString *)tag;
00121 - (void)removeTagFromCurrentDevice:(NSString *)tag;
00122 
00123 // Update (replace) token attributes
00124 - (void)updateAlias:(NSString *)value;
00125 - (void)updateTags:(NSMutableArray *)value;
00126 
00127 // Change quiet time for current device token, only take hh:mm into account
00128 - (void)setQuietTimeFrom:(NSDate *)from to:(NSDate *)to withTimeZone:(NSTimeZone *)tz;
00129 - (void)disableQuietTime;
00130 
00131 - (void)enableAutobadge:(BOOL)enabled;
00132 - (void)setBadgeNumber:(NSInteger)badgeNumber;
00133 - (void)resetBadge;
00134 
00135 //Handle incoming push notifications
00136 - (void)handleNotification:(NSDictionary *)notification applicationState:(UIApplicationState)state;
00137 
00138 + (NSString *)pushTypeString:(UIRemoteNotificationType)types;
00139 
00140 @end
 All Classes Functions Variables Properties