tencent cloud

Chat

제품 소개
제품 개요
Basic Concepts
응용 시나리오
기능 소개
계정 시스템
사용자 정보 및 관계망
메시지 관리
그룹 시스템
Official Account
Audio/Video Call
사용 제한
구매 가이드
과금 개요
요금 안내
Purchase Instructions
Renewal Guide
연체 안내
Refund Policy
다운로드 센터
SDK & Demo 소스 코드
업데이트 로그
시나리오 솔루션
Live Streaming Setup Guide
AI Chatbot
대규모 엔터테인먼트 협업 커뮤니티
Discord 구현 가이드
IM을 게임에 통합하는 방법
WhatsApp Channel-style Official Account Integration Solution
Send Red Packet
Firewall Restrictions
클라이언트 APIs
SDK API(Web)
Android
iOS & macOS
Swift
Flutter
Electron
Unity
React Native
C APIs
C++
서버 APIs
Secure authentication with UserSig
RESTful APIs
Webhooks
콘솔 가이드
New Console Introduction
애플리케이션 생성 및 업그레이드
기본 설정
기능 설정
계정 관리
그룹 관리
Official Channel Management
콜백 설정
모니터링 대시보드
Viewing Guide for Resource Packages
Real-Time Monitor
개발 보조 툴
액세스 관리
Advanced Features
FAQ
uni-app FAQs
구매
SDK 관련 질문
계정 인증
사용자 정보 및 관계망
메시지
그룹
라이브 방송 그룹
닉네임 및 프로필 사진
협약 및 인증
Service Level Agreement
컴플라이언스 인증
IM 정책
개인 정보 보호 정책
데이터 개인 정보 보호 및 보안 계약
에러 코드
문의하기
문서Chat

iOS & macOS

포커스 모드
폰트 크기
마지막 업데이트 시간: 2025-03-20 16:43:48

TIMPush - TIMPushManager

@interface TIMPushManager : NSObject :Push Plugin Interface Class.

API overview

Register/Unregister Push Service Interface

API
Description
Register Push Service (Must be called after the App user has agreed to the privacy policy to use the push service).
Unregister and disable the push service.
RegistrationID is the unique identifier ID of the push receiving device. By default, this ID is automatically generated when the push service is successfully registered, but you can also customize the setting. You can push messages to the specified device based on the RegistrationID. Note that uninstalling and reinstalling the device will change the RegistrationID, so you need to call the setRegistrationID interface before registering the push service.
After successfully registering the push service, you can get the unique identifier ID of the push receiving device, that is, the RegistrationID, by calling the getRegistrationID interface. You can push messages to the specified device based on the RegistrationID.

Push global listening interface

API
Description
Add Push listener.
Remove Push listener.

Custom Configuration Interface

Set whether to display push notifications in the foreground of the app
API
Description
Disable the notification bar when the app is in the foreground.

Statistics for TIMPush's Push Arrival Rate

If you need to track push arrival and click data, you need to proactively call this function in the Notification Service Extension.
API
Description
Only support calling in Notification Service Extension's '- didReceiveNotificationRequest:withContentHandler:' method.
The appGroup identifies the App Group shared between the main app and the Extension. It needs to be configured in the App Groups capability of the main app's capability.

Interface Details

Function description

+ (void)registerPush:(int) sdkAppId appKey:(NSString *) appKey succ:(TIMPushSuccessCallback) successCallback fail:(TIMPushFailedCallback) failedCallback;
Register Push Service. Please correctly pass the parameters sdkAppId and appKey to register the push service.
Parameter description:
Parameter
Description
Get Path
sdkAppId
The application ID assigned to you by the Chat console.



appKey
The client key assigned to you by the Chat console.
Sample code:
const int sdkAppId = your sdkAppId;
static const NSString *appKey = @"Client Key";

[TIMPushManager registerPush:sdkAppId appKey:appKey succ:^(NSData * _Nonnull deviceToken) {
//
} fail:^(int code, NSString * _Nonnull desc) {
//error
}];
+ (void)unRegisterPush:(TIMPushCallback) successCallback fail:(TIMPushFailedCallback) failedCallback;
Unregister and disable the push service
Sample code:
[TIMPushManager unRegisterPush:^{
//success
} fail:^(int code, NSString * _Nonnull desc) {
//error
}];
+ (void)setRegistrationID:(NSString *)registrationID callback: (TIMPushCallback) callback;
Set the push ID identifier used for registering the push service, i.e., RegistrationID, which needs to be called before registering the push service.
Parameter description:
Parameter
Description
registrationID
The device's push identifier ID will change if you uninstall and reinstall.
+ (void)getRegistrationID:(TIMPushValueCallback) callback;
After successfully registering the push service, obtain the push ID identifier, i.e., RegistrationID.
+ (void)addPushListener:(id<TIMPushListener>)listener
Add Push listener.
+ (void)removePushListener:(id<TIMPushListener>)listener
Remove Push listener.
+ (void)disablePostNotificationInForeground:(BOOL)disable;
Disable notification bar pop-ups when the app is in the foreground. When the Push SDK receives an online Push, it will automatically add a Notification to the notification bar. If you want to handle the online Push messages yourself, you can call this interface to disable the automatic notification bar pop-up feature.
Parameter description:
Parameter
Description
disable
true: disable
false: enable
+ (void)handleNotificationServiceRequest:(UNNotificationRequest *)request appGroupID:(NSString *)appGroupID callback:(TIMPushNotificationExtensionCallback)callback
Statistics for TIMPush's Push Arrival Rate
1. You need to implement the `- applicationGroupID` method in the AppDelegate.m file, returning the App Group ID.
2. And call this function in the Notification Service Extension's '- didReceiveNotificationRequest:withContentHandler:' method.
Note:
The appGroup identifies the App Group shared between the main app and the Extension. It needs to be configured in the App Groups capability of the main app's capability.
Parameter description:
request
appGroupID
The appGroup identifies the App Group shared between the main app and the Extension. It needs to be configured in the App Groups capability of the main app's capability.
callback
typedef void(^TIMPushNotificationExtensionCallback)(UNNotificationContent *content) Statistics function callback, carrying content information
Sample code:

@implementation NotificationService

- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
//The appGroup identifies the App Group shared between the main app and the Extension. It needs to be configured in the App Groups capability of the main app's capability.
//Format: group + [mainBundleID] + key
//E.g., group.com.tencent.im.pushkey
NSString * appGroupID = kTIMPushAppGorupKey;
__weak typeof(self) weakSelf = self;
[TIMPushManager handleNotificationServiceRequest:request appGroupID:appGroupID callback:^(UNNotificationContent *content) {
weakSelf.bestAttemptContent = [content mutableCopy];
// Modify the notification content here...
// self.bestAttemptContent.title = [NSString stringWithFormat:@"%@ [modified]", self.bestAttemptContent.title];
weakSelf.contentHandler(weakSelf.bestAttemptContent);
}];
}

@end

TIMPush - TIMPushListener

@protocol TIMPushListener <NSObject> :Push Listener Protocol

API overview

API
Description
onRecvPushMessage
Received Push message
onRevokePushMessage
Received a notification of Push message recall
onNotificationClicked
Notification bar message click callback

Interface Details

Member Function Description

- (void)onRecvPushMessage:(TIMPushMessage *)message;
Received Push message, message content.
- (void)onRevokePushMessage:(NSString *)messageID;
Received a notification of Push message recall, messageID uniquely identifies the message.
- (void)onNotificationClicked:(NSString *)ext;
Notification bar message click callback.

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백