简体   繁体   English

iOS推送通知和GCM

[英]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. 我正在使用GCM在iOS中实现推送通知,当应用程序处于活动状态时,它将收到通知,但是如果其处于非活动状态,则不会显示警报,并等待应用程序变为活动状态以处理该通知。

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. 如果您希望在应用程序处于后台时将仅包含自定义键/值的消息发送到iOS设备,请在数据中设置自定义键/值对,并将content_available设置为true。

I hope this helps you. 我希望这可以帮助你。

First Step - use this method in appDelegate.m 第一步-在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 使GCM在后台运行于iOS设备

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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