Guest User

Untitled

a guest
Dec 9th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.80 KB | None | 0 0
  1. #import "iTalkAlarmAppDelegate.h"
  2.  
  3. @implementation iTalkAlarmAppDelegate
  4.  
  5. @synthesize window;
  6. @synthesize mainView,nav,strAlarmTitle,strAlarmTime,strAlarmSound;
  7. @synthesize strSoundName,selectrow,segmentValue;
  8. @synthesize arrAlarmName,arrAlarmTime,strRepeatName;
  9. @synthesize repeatRow,arrRecorded,intrecord,audio,strRecordPath;
  10. @synthesize deviceToken,payload,certificate;
  11.  
  12.  
  13.  
  14. NSString *kRemindMeNotificationDataKey = @"kRemindMeNotificationDataKey";
  15. #pragma mark -
  16. #pragma mark Application lifecycle
  17.  
  18. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  19.  
  20. // Override point for customization after application launch.
  21. mainView = [[MainView alloc]init];
  22.  
  23. strAlarmTitle=[[NSString alloc]init];
  24. strAlarmTime=[[NSString alloc]init];
  25. strAlarmSound=[[NSString alloc]init];
  26. strSoundName=[[NSString alloc]init];
  27. arrAlarmName=[[NSMutableArray alloc]init];
  28. arrAlarmTime=[[NSMutableArray alloc]init];
  29. strRecordPath=[[NSString alloc]init];
  30. strRepeatName=[[NSMutableArray alloc]init];
  31. audio=[[NSData alloc]init];
  32. arrRecorded=[[NSArray alloc]init];
  33. // nav = [[UINavigationController alloc]initWithRootViewController:mainView];
  34. // self.window.rootViewController=self.nav;
  35. /////////////////////////////////////////////////////
  36.  
  37. SetAlarm *setAlarm=[[SetAlarm alloc]init];
  38.  
  39. Class cls = NSClassFromString(@"UILocalNotification");
  40. if (cls) {
  41. UILocalNotification *notification = [launchOptions objectForKey:
  42. UIApplicationLaunchOptionsLocalNotificationKey];
  43.  
  44. if (notification) {
  45. NSString *reminderText = [notification.userInfo
  46. objectForKey:kRemindMeNotificationDataKey];
  47. [setAlarm showReminder:reminderText];
  48. }
  49. }
  50.  
  51. application.applicationIconBadgeNumber = 0;
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62. ////////////////////////////////////////////////////
  63. self.window.rootViewController=self.mainView;
  64.  
  65. [self.window makeKeyAndVisible];
  66.  
  67.  
  68.  
  69. [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
  70. (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79. return YES;
  80. }
  81.  
  82.  
  83.  
  84.  
  85.  
  86. - (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken1 {
  87.  
  88. NSString *str = [NSString
  89. stringWithFormat:@"Device Token=%@",deviceToken1];
  90. NSLog(@"device......%@",str);
  91.  
  92. }
  93.  
  94. - (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
  95.  
  96. NSString *str = [NSString stringWithFormat: @"Error: %@", err];
  97. NSLog(@"device......%@",str);
  98.  
  99. }
  100.  
  101. - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
  102.  
  103. for (id key in userInfo) {
  104. NSLog(@"key: %@, value: %@", key, [userInfo objectForKey:key]);
  105. }
  106.  
  107. }
  108.  
  109.  
  110. - (id)init {
  111. self = [super init];
  112. if(self != nil) {
  113. //6240d771 c9a0778e 92aa9a3e 5dd712e2 0ec263ad f25ba8b6 635eac5d 8969e5d9
  114. self.deviceToken = @"6240d771 c9a0778e 92aa9a3e 5dd712e2 0ec263ad f25ba8b6 635eac5d 8969e5d9";
  115.  
  116. self.payload = @"{\"aps\":{\"alert\":\"You got a new alarm message!\",\"badge\":5,\"sound\":\"Blow.aiff\"},\"acme1\":\"bar\",\"acme2\":42}";
  117.  
  118. self.certificate = [[NSBundle mainBundle]
  119. pathForResource:@"aps_development" ofType:@"cer"];
  120. }
  121. return self;
  122. }
  123.  
  124.  
  125.  
  126.  
  127. - (void)applicationWillResignActive:(UIApplication *)application {
  128. /*
  129. Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
  130. Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
  131. */
  132. }
  133.  
  134.  
  135. - (void)applicationDidEnterBackground:(UIApplication *)application {
  136. /*
  137. Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
  138. If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
  139. */
  140. }
  141.  
  142.  
  143. - (void)applicationWillEnterForeground:(UIApplication *)application {
  144. application.applicationIconBadgeNumber = 0;
  145. /*
  146. Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
  147. */
  148. }
  149.  
  150.  
  151. - (void)applicationDidBecomeActive:(UIApplication *)application {
  152. /*
  153. Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
  154. */
  155. }
  156.  
  157.  
  158. - (void)applicationWillTerminate:(UIApplication *)application {
  159. /*
  160. Called when the application is about to terminate.
  161. See also applicationDidEnterBackground:.
  162. */
  163. }
  164.  
  165.  
  166. #pragma mark -
  167. #pragma mark Memory management
  168.  
  169. - (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
  170. /*
  171. Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
  172. */
  173. }
  174. - (void)application:(UIApplication *)application
  175. didReceiveLocalNotification:(UILocalNotification *)notification {
  176.  
  177. // UIApplicationState state = [application applicationState];
  178. // if (state == UIApplicationStateInactive) {
  179.  
  180. // Application was in the background when notification
  181. // was delivered.
  182. // }
  183. SetAlarm *setAlarm=[[SetAlarm alloc]init];
  184.  
  185.  
  186. application.applicationIconBadgeNumber = 0;
  187. NSString *reminderText = [notification.userInfo
  188. objectForKey:kRemindMeNotificationDataKey];
  189. [setAlarm showReminder:reminderText];
  190. }
  191.  
  192. - (void)dealloc {
  193. [window release];
  194. [super dealloc];
  195. }
  196.  
  197.  
  198. @end
Add Comment
Please, Sign In to add comment