English | 简体中文
For the overview and console prerequisites (create an app / obtain keys / enable push and configure the APNs channel), please read the parent document first: ../README.md. This document focuses only on the iOS client-side integration.
The Tencent Cloud TIMPush offline-push iOS experience demo. This project is a clean template with nothing configured: the SDKAppID, AppKey, APNs BusinessID, signing, Bundle ID, App Group, and pod install all need to be configured by you as described below before it can build and run.
- You have completed the Common Prerequisites (Console) in the parent document, obtained the SDKAppID / AppKey, and configured the APNs push certificate and BusinessID in the console.
- macOS + Xcode, CocoaPods installed, and a real iOS device ready (the simulator does not support APNs and cannot verify push).
cd iOS
pod installIf CocoaPods is not installed, run
sudo gem install cocoapodsfirst. This generatesPods/andPodfile.lock.
⚠️ You must open the.xcworkspace, not the.xcodeproj, otherwise the Pod dependencies won't be found.
Open pushdemo/TestPushViewController.m and change the placeholders to the actual values obtained in the Prerequisites:
static const int kTIMPushSDKAppID = 0; // change to your SDKAppID
static NSString * const kTIMPushAppKey = @"";// change to your AppKeyOpen pushdemo/PushConstants.h and modify the placeholders in the DEBUG branch:
#ifdef DEBUG
#define kAPNSBusiId 11111 // change to the BusinessID of the APNs channel in the console
#define kTIMPushAppGorupKey @"xxxx" // change to your App Group Identifier (see Step 5.2)The
BUILDAPPSTORE/ enterprise-certificate branches only take effect for Release builds; keep the defaults for normal experience.
For both the pushdemo and pushservice targets, in Signing & Capabilities:
Team: select your own Apple Developer Team.Bundle Identifier: change to your own Bundle ID.pushdemomain App: e.g.com.your-company.timpush.demopushservicepush extension: must be the main App Bundle ID followed by.pushservice, e.g.com.your-company.timpush.demo.pushservice
App Group lets the main App share data with the pushservice push extension and is required by TIMPush.
- Create it in Apple Developer: log in to https://developer.apple.com/account → Identifiers, switch to
App Groups, click+to create one. The Identifier must start withgroup., e.g.group.com.your-company.timpush.demo. - Enable it in Xcode: for both the
pushdemoandpushservicetargets,Signing & Capabilities→+ Capabilityto addApp Groups, then tick thegroup.xxxyou just created. If it can't be ticked, click the refresh button to let Xcode regenerate the profile. - Fill it back into
PushConstants.h: setkTIMPushAppGorupKeyin the DEBUG branch to thatgroup.xxx(i.e. Step 4).
iOS push can only be verified on a real device. Connect a device, select the pushdemo scheme, and Run. Receiving a push means the whole flow works.
Q: Build fails with 'TIMPushManager.h' file not found?
Did you run pod install? Did you open the .xcworkspace or the .xcodeproj? It must be the former.
Q: It runs on the device, but no push is received? Troubleshoot in this order:
- Is the
Push Notificationscapability enabled inSigning & Capabilities? - Is the App Group exactly the same in all three places: Apple Developer / Xcode (both pushdemo + pushservice targets) /
PushConstants.h(DEBUG branch)? - Has the app on the device granted notification permission?
- Did you obtain the RegistrationID? (Check the
TestPushViewControllerUI and logs.)
Q: Provisioning profile doesn't include the com.apple.security.application-groups entitlement?
The App Groups capability wasn't enabled successfully in Xcode. Redo Step 5.2, and click the refresh button to regenerate the profile if needed.