简体   繁体   中英

iOS push notifications and GCM

I'm using GCM to implement push notifications in iOS, when the application is active it will receive the notification, but if its inactive it will not show an alert, and wait for the application to become active to handle it.

The received notification is this:

 [post_title : new post, post_id :1067 lang : english, post_type:  News , from : 865414108428]

From the docs :

If you want to send messages consisting of only custom key/values to an iOS device when the app is in the background, set custom key/value pairs in data and set content_available to true.

I hope this helps you.

First Step - use this method in appDelegate.m

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler

Second see in Image 在此处输入图片说明

Add also check this

Making GCM work for iOS device in the background

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM