12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- //
- // ASPushOneSignalManager.m
- // Asteria
- //
- // Created by xingyu on 2024/7/11.
- //
- #import "ASPushOneSignalManager.h"
- #import <OneSignal/OneSignal.h>
- @interface ASPushOneSignalManager()<UNUserNotificationCenterDelegate>
- @end
- @implementation ASPushOneSignalManager
- + (instancetype)shared {
- static id sharedInstance = nil;
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- sharedInstance = [[self alloc] init];
- });
- return sharedInstance;
- }
- - (void)initOneSignalSDKWithPushConfig:(NSDictionary *)launchOptions {
-
- [OneSignal setLogLevel:ONE_S_LL_VERBOSE visualLevel:ONE_S_LL_NONE];
-
- // OneSignal initialization
- [OneSignal initWithLaunchOptions:launchOptions];
- [OneSignal setAppId:@"618fe580-bc97-4bf4-b2bb-5039f9dbbc82"];
- // promptForPushNotifications will show the native iOS notification permission prompt.
- // We recommend removing the following code and instead using an In-App Message to prompt for notification permission (See step 8)
- [OneSignal promptForPushNotificationsWithUserResponse:^(BOOL accepted) {
- NSLog(@"User accepted notifications: %d", accepted);
- }];
-
- }
- #pragma mark ---- 设置用户推送标签 ----
- - (void)setPushApnsTagWithUserInfo {
-
- if ([ASUserInfoManager shared].isLogin) {
- ASUserModel *userInfo = [[ASUserInfoManager shared] userInfo];
- if (!userInfo.Id.isEmpty) {
- NSInteger sufix = userInfo.Id.integerValue%10;
- [OneSignal sendTag:@"SufixUid" value:[NSString stringWithFormat:@"%ld", sufix]];
- }
- if (userInfo.group_id.intValue == 5) {
- [OneSignal sendTag:@"IsOrdered" value:@"true"];
- #if (DEBUG)
- [OneSignal sendTag:@"testOrderd" value:@"true"];
- #endif
- } else {
- #if (DEBUG)
- [OneSignal deleteTag:@"testOrderd"];
- #endif
- [OneSignal deleteTag:@"IsOrdered"];
- }
-
- } else {
- [OneSignal sendTag:@"SufixUid" value:@"-"];
- }
- }
- @end
|