2023-07-10 17:50:31 +08:00
|
|
|
|
#import "AppDelegate.h"
|
2023-11-01 14:18:52 +08:00
|
|
|
|
|
2023-07-10 17:50:31 +08:00
|
|
|
|
#import "GeneratedPluginRegistrant.h"
|
2023-10-14 17:08:25 +08:00
|
|
|
|
#import "CommonDefine.h"
|
2023-11-01 14:18:52 +08:00
|
|
|
|
#import "XSFlutterManager.h"
|
|
|
|
|
|
|
|
|
|
|
|
#import <UserNotifications/UserNotifications.h>
|
2024-10-19 18:26:41 +08:00
|
|
|
|
#import <UMCommon/UMCommon.h>
|
2023-11-01 14:18:52 +08:00
|
|
|
|
|
2024-03-19 18:26:07 +08:00
|
|
|
|
|
2023-11-01 14:18:52 +08:00
|
|
|
|
@interface AppDelegate()
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@implementation AppDelegate {
|
|
|
|
|
|
}
|
2023-07-10 17:50:31 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (BOOL)application:(UIApplication *)application
|
|
|
|
|
|
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
2023-11-01 14:18:52 +08:00
|
|
|
|
|
2024-10-21 18:13:21 +08:00
|
|
|
|
[UMConfigure initWithAppkey:@"671244ae80464b33f6df9646" channel:@"Product"];
|
2024-10-19 18:26:41 +08:00
|
|
|
|
|
2023-11-01 14:18:52 +08:00
|
|
|
|
XSFlutterManager *VC = [[XSFlutterManager alloc] init];
|
2023-10-16 17:18:10 +08:00
|
|
|
|
self.window.rootViewController = VC;
|
|
|
|
|
|
[self.window makeKeyAndVisible];
|
2023-11-01 14:18:52 +08:00
|
|
|
|
|
2023-10-16 17:18:10 +08:00
|
|
|
|
return YES;
|
2023-07-10 17:50:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-17 14:29:13 +08:00
|
|
|
|
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
|
|
|
|
|
|
// 判断是否是你的应用程序的 URL Scheme
|
|
|
|
|
|
if ([url.scheme isEqualToString:@"skysmartlock"]) {
|
|
|
|
|
|
// 处理被唤起的逻辑,可以根据 URL 中的其他信息来执行相应的操作
|
|
|
|
|
|
return YES;
|
|
|
|
|
|
}
|
|
|
|
|
|
return NO;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-11-01 14:18:52 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 注册苹果推送,获取deviceToken用于推送
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param application
|
|
|
|
|
|
*/
|
|
|
|
|
|
- (void)registerAPNS:(UIApplication *)application {
|
|
|
|
|
|
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
|
|
|
|
|
|
// iOS 8 Notifications
|
|
|
|
|
|
[application registerUserNotificationSettings:
|
|
|
|
|
|
[UIUserNotificationSettings settingsForTypes:
|
2024-06-06 15:56:23 +08:00
|
|
|
|
(UIUserNotificationTypeSound | UIUserNotificationTypeAlert)
|
2023-11-01 14:18:52 +08:00
|
|
|
|
categories:nil]];
|
|
|
|
|
|
[application registerForRemoteNotifications];
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
// iOS < 8 Notifications
|
|
|
|
|
|
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
|
2024-06-06 15:56:23 +08:00
|
|
|
|
(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
|
2023-11-01 14:18:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
|
|
|
* 苹果推送注册成功回调,将苹果返回的deviceToken上传到CloudPush服务器
|
|
|
|
|
|
*/
|
|
|
|
|
|
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
2024-09-11 17:49:36 +08:00
|
|
|
|
|
2024-03-19 18:26:07 +08:00
|
|
|
|
//sdk注册DeviceToken
|
|
|
|
|
|
[JPUSHService registerDeviceToken:deviceToken];
|
|
|
|
|
|
|
2023-11-01 14:18:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
|
|
|
* 苹果推送注册失败回调
|
|
|
|
|
|
*/
|
|
|
|
|
|
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
|
|
|
|
|
|
NSLog(@"didFailToRegisterForRemoteNotificationsWithError %@", error);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 注册推送消息到来监听
|
|
|
|
|
|
*/
|
|
|
|
|
|
- (void)registerMessageReceive {
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
|
|
selector:@selector(onMessageReceived:)
|
|
|
|
|
|
name:@"CCPDidReceiveMessageNotification"
|
|
|
|
|
|
object:nil];
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 处理到来推送消息
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param notification
|
|
|
|
|
|
*/
|
|
|
|
|
|
- (void)onMessageReceived:(NSNotification *)notification {
|
|
|
|
|
|
CCPSysMessage *message = [notification object];
|
|
|
|
|
|
NSString *title = [[NSString alloc] initWithData:message.title encoding:NSUTF8StringEncoding];
|
|
|
|
|
|
NSString *body = [[NSString alloc] initWithData:message.body encoding:NSUTF8StringEncoding];
|
|
|
|
|
|
NSLog(@"Receive message title: %@, content: %@.", title, body);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-07-10 17:50:31 +08:00
|
|
|
|
@end
|