推送-个推的使用总结

来源:网络整理   2018-09-19 01:40  编辑:admin  人气:

gt.png

1、报户口个推平台账号。

2、使被安排好推进运动音讯运用,填写声请通讯,Android填空包名。,IOS平台分为开拓周围和形状周围。,可以独立使被安排好运用。,向上负载实质性的的P12证明和APN密码电文。 或许在论文上部位时掉换正式的周围证明。,10分钟失效。

3、论文集成,排列AppID、AppSecret、AppKey。

4、在didFinishLaunchingWithOptions中开启个推。

- (BOOL)运用:(UIAp声请) *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   [GeTuiSdk startSdkWithAppId:kGtAppId appKey:kGtAppKey appSecret:kGtAppSecret 代表:同一的
}

因此报户口遥控器推进运动。,次序无法变坏。!

用户权利声请表
if ([[UIDevice currentDevice].systemVersion floatValue] >= ) {
    [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:UNAuthorizationOptionBadge|UNAuthorizationOptionSound|UNAuthorizationOptionAlert|UNAuthorizationOptionCarPlay completionHandler:^(BOOL granted, NSError * _Nullable 逆) {
        在块中引入乔治英国数学家和逻辑学家值赋予。,教用户倘若约定。
        if (容许) {
            免得用户权利成,设置布告磁心代劳
            dispatch_async(dispatch_get_main_queue(), ^{
                [[UIApplication sharedApplication] registerForRemoteNotifications];
            });
        }
    }];
}else{
    UIApplication *app = [UIApplication sharedApplication];
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound 类别:零
    
    if (运用 respondsToSelector:@selector(registerUserNotificationSettings:)]) {
        NSLog(报户口布告)
        运用 registerUserNotificationSettings:settings];
    } else {
        NSLog(@)及以下 报户口布告
        运用 registerForRemoteNotificationTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound];
    }
}

5、以报户口成的方法处置苹果后退的安装。,拆下托架的两端和中心区的空格。

  - (空)功用:(UIAp声请) *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
      NSString *token = [[deviceToken 形容 stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
      token = [代币] stringByReplacingOccurrencesOfString:@" " withString:@""];
      // 向个推服侍报户口deviceToken
      [GeTuiSdk registerDeviceToken:token];
}

6、报户口clientId 绑定别号功用:底色可按别号推进运动。

  - (void)GeTuiSdkDidRegisterClient:(NSString *)clientId {
      [GeTuiSdk bindAlias:alias andSequenceNum:clientId];
  }

7、接纳遥控器布告音讯

  #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
  //  iOS 10: APP在舞台前部装置收到布告。
  - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {

      MyLog(@"willPresentNotification:%@", );
// 基本原则运用需要的东西,决议倘若提词用户典型、Sound、Alert
      completionHandler(UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert);
  }

  //  iOS 10: 点击进入运用的布告
  - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler {

      MyLog(@"didReceiveNotification:%@", 反作用力。
      // [ GTSdk ]:将收到的APNs通讯传给个推计算总数
      [GeTuiSdk handleRemoteNotification:response.];
      completionHandler(UIBackgroundFetchResultNewData);
  }
  #endif


  - (空)功用:(UIAp声请) *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
      // 将收到的APNs通讯传给个推计算总数
      [GeTuiSdk handleRemoteNotification:userInfo];
      completionHandler(UIBackgroundFetchResultNewData);
  }

8、接纳传输音讯。,个推iOS推进运动,免得运用在舞台前部装置运转,音讯走透传,免得你在底色运转,音讯走布告,开拓周围尺寸推,你仅仅传输音讯。,布告音讯只倒退Android。且接纳传输音讯。,无布告条提词。

  - (void)GeTuiSdkDidReceivePayloadData:(NSData *)payloadData andTaskId:(NSString *)taskId andMsgId:(NSString *)msgId 脱机:(BOOL)脱机 fromGtAppId:(NSString *)appId {
         NSDictionary *dict = nil;
          if (payloadData) {
              dict = [NSJSONSerialization JSONObjectWithData:payloadData options:NSJSONReadingAllowFragments 离经叛道的行为:零
              NSLog(@"************接接纳传输音讯。*************************%@",DICT)
          }
  }

(1)反省AppID。 、AppKey、AppTebug排列弥撒书的章节吗?
(2)反省安装倘若契合向上负载周围。


检测

(3)反省一下开启个推和报户口遥控器布告的次
(4)注重在尺寸时无布告栏。,可以检测代劳ReC中倘若接纳到推进运动音讯。。

======================================================
谈有垒线的======================================================