IOS Push (GTSDK)2.4.1 update 2.5.3 update and learning summary

A push principle

  1. First, the push message is sent from the server to the push server, and then the push server determines whether the user is online or not. If the user is online, the push content will be called to the agent method implemented in the application; if not, the push will be pushed to the Apple server through the APNS server, and then the Apple service will deliver the notification.

New and old versions update the difference

Notification message

  1. Old version processing logic
When 2.4.1 is used, the back-end sends notification messages without any processing. Because only when the application goes into the background will there be a push message popover, and when the application goes into the foreground and receives a notification message, there will be no pick-up message popoverCopy the code
  1. The new version adds a registration notification method and a proxy method
Registration method + (void) registerRemoteNotification (UNAuthorizationOptions) types;Copy the code

When the developer needs to be in the application front end of the time to receive a push to do processing if the need to call this method registration notification

Agents receive push method - (void) GeTuiSdkNotificationCenter: (UNUserNotificationCenter *) center willPresentNotification: (UNNotification *)notification completionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler;Copy the code

If the server sends a notification message, the application is online and the registration method is invoked. If the registration method is registered, this method is used. The advantage of this method is that the developer can handle whether to set pop-ups, sounds and red dots in the foreground of the program. In the process of live, for example, receive message if don’t want to have a popup window display, simply the completionHandler not join UNNotificationPresentationOptionAlert the call.

Transparent messaging (foreground)

  1. The old version receives the pass-through proxy method
- (void)GeTuiSdkDidReceivePayloadData:(NSData *)payloadData 
                            andTaskId:(NSString *)taskId 
                             andMsgId:(NSString *)msgId 
                           andOffLine:(BOOL)offLine fromGtAppId:(NSString *)appId;
Copy the code
  1. New version of receive transparent transmission agent method
- (void)GeTuiSdkDidReceiveSlience:(NSDictionary *)userInfo
                        fromGetui:(BOOL)fromGetui
                          offLine:(BOOL)offLine
                            appId:(nullable NSString *)appId
                           taskId:(nullable NSString *)taskId
                            msgId:(nullable NSString *)msgId
           fetchCompletionHandler:(nullable void (^)(UIBackgroundFetchResult))completionHandler;
Copy the code
  1. The new version is the same in functionality, only sending transparent messages, but the difference is that the new version returns the dictionary with payloadData as one of the fields in the dictionary. When the application enters the background, the server sends transparently transmitted messages to the user through APNS. Therefore, when the application enters the background, there can be popover messages received through transparently transmitted messages.

Custom ringtone Settings for iOS receiving messages

  1. Add the audio file to the project’s root directory,
  2. Add the audio file to Build Phases->Copy Bundle Resources
  3. Set the full name of the file name in setSound in apnInfo when pushing
  4. Once you’ve set it up, you can play custom ringtones when pushed