Files
FinalYearProject-MyMind/My Broken Mind/My Mind/AmazonAws/AWSMobileHubHelper.framework/Headers/AWSPushManager.h
Alexander Davis 0018e82ee5 App Completed
Basic Prototype App Completed. Proposal, Literature Review and Final
Report to Follow.
2017-04-13 18:18:38 +01:00

501 lines
19 KiB
Objective-C
Executable File

//
// AWSPushManager.h
//
// Copyright 2016 Amazon.com, Inc. or its affiliates (Amazon). All Rights Reserved.
//
// Code generated by AWS Mobile Hub. Amazon gives unlimited permission to
// copy, distribute and modify it.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <AWSCore/AWSCore.h>
NS_ASSUME_NONNULL_BEGIN
/**
The error domain for `PushManager`.
*/
FOUNDATION_EXPORT NSString *const AWSPushManagerErrorDomain;
/**
The error code for `AWSPushManagerErrorDomain`.
*/
typedef NS_ENUM(NSInteger, AWSPushManagerErrorType){
/**
An unknown error. This should not happen.
*/
AWSPushManagerErrorTypeUnknown,
/**
The device token returned by the OS is invalid and cannot be processed.
*/
AWSPushManagerErrorTypeInvalidDeviceToken,
/**
Unsubscribe requests failed while disabling `PushManager`.
*/
AWSPushManagerErrorTypeUnsubscribeFailed,
};
@class AWSPushManager;
@class AWSPushTopic;
@class AWSPushManagerConfiguration;
@protocol AWSPushManagerDelegate;
@protocol AWSPushTopicDelegate;
/**
The Push Manager registers the app on the device with Apple Push Notification Service (APNS) and registers the resulting device token in Amazon SNS. The result of this registration process is an Amazon SNS Endpoint ARN, which can be used to send push notifications directly to a specific device. The Push Manager also manages Amazon SNS topic subscriptions, allowing the app to subscribe to Amazon SNS topics, which let you target groups of devices with push notifications. Requires the AWSSNS framework of AWSiOSSDK.
*/
@interface AWSPushManager : NSObject
/**
Indicates if `PushManager` is enabled or disabled.
*/
@property (nonatomic, readonly, getter=isEnabled) BOOL enabled;
/**
The device token returned by iOS.
*/
@property (nonatomic, readonly, nullable) NSString *deviceToken;
/**
The application platform endpoint ARN for Amazon SNS.
*/
@property (nonatomic, readonly, nullable) NSString *endpointARN;
/**
The application platform ARN for the app.
*/
@property (nonatomic, readonly, nullable) NSString *platformARN;
/**
A list of topic ARNs selected during project configuraiton on AWS Mobile Hub from the `Info.plist` file.
If a custom helper client is used, it would contain the topic ARNs specified in AWSPushManagerConfiguration object.
*/
@property (nonatomic, readonly, nullable) NSArray<NSString *> * topicARNs;
/**
The list of `PushTopic`.
*/
@property (nonatomic, readonly) NSArray<AWSPushTopic *> *topics;
/**
The delegate for receiving `PushManager` and `PushTopic` events.
*/
@property (nonatomic, weak) id<AWSPushManagerDelegate, AWSPushTopicDelegate> delegate;
/**
Returns the default Push Manager singleton instance configured using the information provided in `Info.plist` file.
*Swift*
let pushManager = AWSPushManager.default()
*Objective-C*
AWSPushManager *pushManager = [AWSPushManager defaultPushManager];
*/
+ (instancetype)defaultPushManager;
/**
Creates a helper client for `AWSPushManager` for specified configuration with mentioned key.
Use this method only if you require a helper client with specific configuration.
For example, set the configuration in `- application:didFinishLaunchingWithOptions:`
*Swift*
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider)
AWSServiceManager.default().defaultServiceConfiguration = configuration
let pushManagerConfiguration = AWSPushManagerConfiguration(snsPlatformARN: "SNS_PLATFORM_ARN")
AWSPushManager.register(with: pushManagerConfiguration, forKey: "defaultPushManager")
return true
}
*Objective-C*
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
identityPoolId:@"YourIdentityPoolId"];
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2
credentialsProvider:credentialsProvider];
AWSServiceManager.defaultServiceManager.defaultServiceConfiguration = configuration;
AWSPushManagerConfiguration *pushManagerConfiguration = [[AWSPushManager alloc] initWithSNSPlatformARN:@"SNS_PLATFORM_ARN"];
[AWSPushManager registerPushManagerWithConfiguration:pushManagerConfiguration
forKey:@"defaultPushManager"];
return YES;
}
Then call the following to get the helper client:
*Swift*
let pushmanager = AWSPushManager(forKey: "defaultPushManager")
*Objective-C*
AWSPushManager *pushmanager = [AWSPushManager pushManagerForKey:@"defaultPushManager"];
@warning After calling this method, do not modify the configuration object. It may cause unspecified behaviors.
@param pushManagerConfiguration AWSPushManagerConfiguration object for the manager.
@param key A string to identify the helper client.
*/
+ (void)registerPushManagerWithConfiguration:(AWSPushManagerConfiguration *)pushManagerConfiguration
forKey:(NSString *)key;
/**
Retrieves the helper client associated with the key. You need to call `+ registerPushManagerWithConfiguration:forKey:` before invoking this method. If `+ registerPushManagerWithConfiguration:forKey:` has not been called in advance or the key does not exist, this method returns `nil`.
*Swift*
let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider)
AWSServiceManager.default().defaultServiceConfiguration = configuration
let pushManagerConfiguration = AWSPushManagerConfiguration(snsPlatformARN: "SNS_PLATFORM_ARN")
AWSPushManager.register(with: pushManagerConfiguration, forKey: "defaultPushManager")
*Objective-C*
AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
identityPoolId:@"YourIdentityPoolId"];
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2
credentialsProvider:credentialsProvider];
AWSServiceManager.defaultServiceManager.defaultServiceConfiguration = configuration;
AWSPushManagerConfiguration *pushManagerConfiguration = [[AWSPushManager alloc] initWithSNSPlatformARN:@"SNS_PLATFORM_ARN"];
[AWSPushManager registerPushManagerWithConfiguration:pushManagerConfiguration
forKey:@"defaultPushManager"];
Then call the following to get the helper client:
*Swift*
let Pushmanager = AWSPushManager(forKey: "defaultPushManager")
*Objective-C*
AWSPushManager *Pushmanager = [AWSPushManager PushManagerForKey:@"defaultPushManager"];
@param key A string to identify the helper client.
@return An instance of AWSPushManager for specified key.
*/
+ (instancetype)PushManagerForKey:(NSString *)key;
/**
Removes the helper client associated with the key and release it.
*Swift*
AWSPushManager.remove(forKey: "USWest2PushManager")
*Objective-C*
[AWSPushManager removePushManagerForKey:@"USWest2PushManager"];
@warning Before calling this method, make sure no method is running on this client.
@param key A string to identify the helper client.
*/
+ (void)removePushManagerForKey:(NSString *)key;
/**
Initializes `PushManager` with the list of topic ARNs.
@param topicARNs A list of topic ARNs from Amazon SNS. It needs to be an `NSArray` containing only `NSString`.
*/
- (void)registerTopicARNs:(NSArray<NSString *> *)topicARNs;
/**
Returns a topic associated with the specified topic ARN.
@param topicARN A topic ARN from Amazon SNS.
@return The topic with the specified topic ARN.
*/
- (AWSPushTopic *)topicForTopicARN:(NSString *)topicARN;
/**
Initiates the process to enable Push Notifications.
When called for the first time, it asks the user for the permission to enable Push Notifications. If the user decline it, it fails to enable Push Notifications.
On success, it calls `- pushManagerDidRegister:` from `AWSPushManagerDelegate`.
On failure, it calls `- pushManager:didFailToRegisterWithError:` from `AWSPushManagerDelegate`.
*/
- (void)registerForPushNotifications;
/**
Unsubscribes from all subscribed topics, then marks `PushManager` as disabled.
On success, it calls `- pushManagerDidDisable:` from `AWSPushManagerDelegate`.
On failure, it calls `- pushManager:didFailToDisableWithError:` from `AWSPushManagerDelegate`.
*/
- (void)disablePushNotifications;
/**
Intercepts the `- application:didFinishLaunchingWithOptions:` application delegate.
@param application Your singleton app object.
@param launchOptions A dictionary indicating the reason the app was launched (if any). The contents of this dictionary may be empty in situations where the user launched the app directly. For information about the possible keys in this dictionary and how to handle them, see Launch Options Keys.
*/
- (BOOL)interceptApplication:(UIApplication *)application
didFinishLaunchingWithOptions:(nullable NSDictionary *)launchOptions;
/**
Intercepts the `- application:didRegisterForRemoteNotificationsWithDeviceToken:` application delegate.
@param application The app object that initiated the remote-notification registration process.
@param deviceToken A token that identifies the device to APNs.
*/
- (void)interceptApplication:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken;
/**
Intercepts the `- application:didFailToRegisterForRemoteNotificationsWithError:` application delegate.
@param application The app object that initiated the remote-notification registration process.
@param error An `NSError` object that encapsulates information why registration did not succeed.
*/
- (void)interceptApplication:(UIApplication *)application
didFailToRegisterForRemoteNotificationsWithError:(nullable NSError *)error;
/**
Intercepts the `- application:didReceiveRemoteNotification:` application delegate.
@param application The app object that received the remote notification.
@param userInfo A dictionary that contains information related to the remote notification, potentially including a badge number for the app icon, an alert sound, an alert message to display to the user, a notification identifier, and custom data. The provider originates it as a JSON-defined dictionary that iOS converts to an `NSDictionary` object; the dictionary may contain only property-list objects plus `NSNull`.
*/
- (void)interceptApplication:(UIApplication *)application
didReceiveRemoteNotification:(nullable NSDictionary *)userInfo;
@end
/**
A topic object.
*/
@interface AWSPushTopic : NSObject
/**
Initializes the topic object with a given topic ARN.
@param topicARN A topic ARN from Amazon SNS.
@return An initialized instance of `PushTopic`.
*/
- (instancetype)initWithTopicARN:(NSString *)topicARN
pushManager:(AWSPushManager *)pushManager;
/**
The topic ARN.
*/
@property (nonatomic, readonly) NSString *topicARN;
/**
The topic name.
*/
@property (nonatomic, readonly) NSString *topicName;
/**
Indicates if the device is registered for the topic.
*/
@property (nonatomic, readonly, getter=isSubscribed) BOOL subscribed;
/**
The subscription ARN from Amazon SNS.
*/
@property (nonatomic, readonly, nullable) NSString *subscriptionARN;
/**
Subscribes the device to the topic.
On success, it calls `- topicDidSubscribe:` from `AWSPushTopicDelegate`.
On failure, it calls `topic:didFailToSubscribeWithError:` from `AWSPushTopicDelegate`.
*/
- (void)subscribe;
/**
Unsubscribes the device from the topic.
On success, it calls `- topicDidUnsubscribe:` from `AWSPushTopicDelegate`.
On failure, it calls `topic:didFailToUnsubscribeWithError:` from `AWSPushTopicDelegate`.
*/
- (void)unsubscribe;
@end
/**
A delegate for receiving `PushManager` events.
*/
@protocol AWSPushManagerDelegate <NSObject>
@required
/**
Indicates the success of the `- registerForPushNotifications` call.
@param pushManager An instance of `PushManager`.
*/
- (void)pushManagerDidRegister:(AWSPushManager *)pushManager;
/**
Indicates the failure of the `- registerForPushNotifications` call.
@param pushManager An instance of `PushManager`.
@param error An `NSError` object that encapsulates information why registration did not succeed.
*/
- (void)pushManager:(AWSPushManager *)pushManager
didFailToRegisterWithError:(NSError *)error;
/**
Indicates the device received a Push Notifiation.
@param userInfo A dictionary that contains information related to the remote notification, potentially including a badge number for the app icon, an alert sound, an alert message to display to the user, a notification identifier, and custom data. The provider originates it as a JSON-defined dictionary that iOS converts to an `NSDictionary` object; the dictionary may contain only property-list objects plus `NSNull`.
*/
- (void)pushManager:(AWSPushManager *)pushManager
didReceivePushNotification:(NSDictionary *)userInfo;
/**
Indicates the success of the `- disablePushNotifications` call.
@param pushManager An instance of `PushManager`.
*/
- (void)pushManagerDidDisable:(AWSPushManager *)pushManager;
/**
Indicates the failure of the `- disablePushNotifications` call.
@param pushManager An instance of `PushManager`.
@param error An `NSError` object that encapsulates information why disable did not succeed.
*/
- (void)pushManager:(AWSPushManager *)pushManager
didFailToDisableWithError:(NSError *)error;
@end
/**
A delegate for receiving `PushTopic` events.
*/
@protocol AWSPushTopicDelegate <NSObject>
@required
/**
Indicates the subscribe succeeded.
@param topic The topic object.
*/
- (void)topicDidSubscribe:(AWSPushTopic *)topic;
/**
Indicates the subscribe failed.
@param topic The topic object.
@param error An `NSError` object that encapsulates information why subscribe did not succeed.
*/
- (void)topic:(AWSPushTopic *)topic
didFailToSubscribeWithError:(NSError *)error;
/**
Indicates the unsubscribe succeeded.
@param topic The topic object.
*/
- (void)topicDidUnsubscribe:(AWSPushTopic *)topic;
/**
Indicates the unsubscribe failed.
@param topic The topic object.
@param error An `NSError` object that encapsulates information why unsubscribe did not succeed.
*/
- (void)topic:(AWSPushTopic *)topic
didFailToUnsubscribeWithError:(NSError *)error;
@end
/**
* `AWSPushManagerConfiguration` is the configuration object for `AWSPushManager` class.
*/
@interface AWSPushManagerConfiguration : NSObject
@property (nonatomic, readonly, nullable) AWSServiceConfiguration *serviceConfiguration;
@property (nonatomic, readonly) NSString *platformARN;
@property (nonatomic, readonly, nullable) NSArray<NSString *> *topicARNs;
/**
Returns an instance of `AWSPushManagerConfiguration`. Use this as the configuration object for AWSPushManager.
*Swift*
let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
let configuration = AWSServiceConfiguration(region: .USWest2, credentialsProvider: credentialProvider)
AWSServiceManager.default().defaultServiceConfiguration = configuration
let pushManagerConfiguration = AWSPushManagerConfiguration(snsPlatformARN: "SNS_PLATFORM_ARN")
AWSPushManager.register(with: pushManagerConfiguration, forKey: "defaultPushManager")
*Objective-C*
AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
identityPoolId:@"YourIdentityPoolId"];
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSWest2
credentialsProvider:credentialsProvider];
AWSServiceManager.defaultServiceManager.defaultServiceConfiguration = configuration;
AWSPushManagerConfiguration *pushManagerConfiguration = [[AWSPushManager alloc] initWithSNSPlatformARN:@"SNS_PLATFORM_ARN"];
[AWSPushManager registerPushManagerWithConfiguration:pushManagerConfiguration
forKey:@"defaultPushManager"];
@param snsPlatformARN The SNS Platform ARN
@return an instance of `AWSPushManagerConfiguration`
*/
- (instancetype)initWithPlatformARN:(NSString *)platformARN;
/**
Returns an instance of `AWSPushManagerConfiguration`. Use this as the configuration object for AWSPushManager.
*Swift*
let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId")
let configuration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: credentialProvider)
let pushManagerConfiguration = AWSPushManagerConfiguration(snsPlatformARN: "SNS_PLATFORM_ARN", topicARNs: nil, serviceConfiguration: configuration)
AWSPushManager.register(with: pushManagerConfiguration, forKey: "defaultPushManager")
*Objective-C*
AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1
identityPoolId:@"YourIdentityPoolId"];
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1
credentialsProvider:credentialsProvider];
AWSPushManagerConfiguration *pushManagerConfiguration = [[AWSPushManager alloc] initWithSNSPlatformARN:@"SNS_PLATFORM_ARN"
topicARNs:nil
serviceConfiguration:configuration];
[AWSPushManager registerPushManagerWithConfiguration:pushManagerConfiguration
forKey:@"defaultPushManager"];
@param platformARN The SNS Platform ARN
@param topicARN The list of SNS topics that could be registered
@param serviceConfiguration AWSServiceConfiguration object; nil for default configuration
@return an instance of `AWSPushManagerConfiguration`
*/
- (instancetype)initWithPlatformARN:(NSString *)platformARN
topicARNs:(nullable NSArray<NSString *> *)topicARNs
serviceConfiguration:(nullable AWSServiceConfiguration *)serviceConfiguration;
@end
NS_ASSUME_NONNULL_END