app-starlock/ios/Runner/AppDelegate.m

103 lines
3.1 KiB
Mathematica
Raw Normal View History

2023-07-10 17:50:31 +08:00
#import "AppDelegate.h"
2023-07-10 17:50:31 +08:00
#import "GeneratedPluginRegistrant.h"
2023-10-14 17:08:25 +08:00
#import "CommonDefine.h"
#import "XSFlutterManager.h"
#import <UserNotifications/UserNotifications.h>
#import <UMCommon/UMCommon.h>
@interface AppDelegate()
@end
@implementation AppDelegate {
}
2023-07-10 17:50:31 +08:00
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
2024-10-21 18:13:21 +08:00
[UMConfigure initWithAppkey:@"671244ae80464b33f6df9646" channel:@"Product"];
XSFlutterManager *VC = [[XSFlutterManager alloc] init];
self.window.rootViewController = VC;
[self.window makeKeyAndVisible];
return YES;
2023-07-10 17:50:31 +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;
}
/**
* deviceToken
*
* @param application
*/
- (void)registerAPNS:(UIApplication *)application {
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
// iOS 8 Notifications
[application registerUserNotificationSettings:
[UIUserNotificationSettings settingsForTypes:
(UIUserNotificationTypeSound | UIUserNotificationTypeAlert)
categories:nil]];
[application registerForRemoteNotifications];
}
else {
// iOS < 8 Notifications
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
}
}
/*
* deviceTokenCloudPush
*/
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
//sdkDeviceToken
[JPUSHService registerDeviceToken:deviceToken];
}
/*
*
*/
- (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