Channel Developers

If your service already provides push notifications, you can skip the steps below.

  1. Generate a key with the Apple Push Notification Service enabled on the Certificates, Identifiers & Profiles > Keys page.

  1. Retrieve your Key ID. Please be aware that you can download the issued credential key only once.

  1. Check Team ID in. Account > Membership page.

  1. Navigate to Account > Membership tab, and verify your Team ID.

  1. Launch ChannelTalk (PC), and navigate to the Settings > Security and Development > Mobile SDK Push Section.

  1. Upload the downloaded Key file, and provide the Key ID, Bundle ID, and Team ID.

Registering the device token using initPushToken to receive remote notifications in Channel.

Refer to the example below, add initPushToken to the application(_:didRegisterForRemoteNotificationsWithDeviceToken:) method.

Swift
Objective-C

When a Channel Talk remote notification arrives in the background or terminated state, you can save the notification to display it appropriately when the app is in the foreground state.

Here is an example of what happens when the user taps the push notification. If it is a Channel Talk notification, it notifies Channel Talk that you have received a push notification and saves it.

Swift
Objective-C

If you have successfully stored Channel Talk remote notifications using the storePushNotification, you can open a chat containing saved push messages via the openStoredPushNotification method.

Add the following example to the ViewController where you want to open the Channel Talk chat.

Plaintext
class ViewController : UIViewController {
  override func viewDidLoad() {
    super.viewDidLoad()
    
    if ChannelIO.hasStoredPushNotification() {
      ChannelIO.openStoredPushNotification()
    }
  }
}
Plaintext
@implementation ViewController

- (void)viewDidLoad { 
	[super viewDidLoad]; 

	if ([ChannelIO hasStoredPushNotification]) {
		[ChannelIO openStoredPushNotification]
	}
}

@end

To prevent push notifications and SMS from being delivered simultaneously, you need to notify Channel when a remote notification arrives.

Navigate to the Capabilities tab and add Background Mode. Enable both Background fetch and Remote notification.

Then, add the receivePushNotification method to notify Channel that a push notification has arrived successfully. Refer to the example below:

Swift
Objective-C

This extension enables appropriate handling of Channel Talk remote push notifications, even when the app is running in the background or has been terminated.

Channel Talk recommends adding this Extension. If you do not add this, you may receive both follow-up text messages and remote notifications.

  1. From the Xcode Menu, Click File > New > Target… .

  2. In the select a new target window, click Notification Service Extension.

Xcode creates a new Target. For Swift, you can see two generated files, and three for Objective-C.

The description of the newly generated file are as follows:

  • NotificationService.swift : Write the code used inside the extension target.

  • Info.plist : info.plist file of extension Target

Add the SDK dependency to the newly created Extension Target. Modify the Podfile as follows:

Ruby
  1. Navigate to the project settings for the newly created target.

  2. Go to the General tab.

  3. Add the ChannelIOFront package to the Frameworks and Libraries category.

Add the following example based on your project language settings.

Swift
Objective-C