iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
pheyer
V2EX  ›  iDev

推送消息可以撤销?

  •  
  •   pheyer · Oct 29, 2015 · 6246 views
    This topic created in 3876 days ago, the information mentioned may be changed or developed.
    刚才收到提醒,扫了一下屏幕(锁屏状态)有两条推送消息,可就在这一会儿,顶部的那条消息消失然后只变成一条推送消息了,难道说推送消息现在可以撤销了?
    系统是 iOS9.1
    20 replies    2015-10-30 10:42:07 +08:00
    bestsanmao
        1
    bestsanmao  
       Oct 29, 2015
    应该可以
    我用 outlook ios 版收邮件
    每当有新邮件推送提醒时(锁屏状态 亮屏提醒)
    我在电脑上用 web 方式查看邮件后 锁屏界面的通知就没了
    laoyur
        2
    laoyur  
       Oct 29, 2015
    好神奇,一直都只有取消 Local Notification 的 API ,居然能操纵 Push Notification ?而且是在 app 没有运行的情况下
    是我孤陋寡闻了吗?关注
    hahasong
        3
    hahasong  
       Oct 29, 2015
    当然可以,至少安卓是可以的
    laoyur
        4
    laoyur  
       Oct 29, 2015
    @hahasong talk is cheap, show me the code
    qinxg
        5
    qinxg  
       Oct 29, 2015
    看 QQ 啊 QQ 手机消息电脑收了 推送就消失了
    laoyur
        7
    laoyur  
       Oct 29, 2015
    @hahasong 嗯,不过我们讨论的是 iOS ,我是针对你斩钉截铁的“当然可以”来发问的
    hahasong
        8
    hahasong  
       Oct 29, 2015
    @laoyur 注意我后半句的条件限定。另 5L 用事实说明了一切
    r00tt
        9
    r00tt  
       Oct 29, 2015
    @hahasong 我猜测 @laoyur 的意思是 iOS 上接受到服务器的 push notification 是无法取消的
    fox
        10
    fox  
       Oct 29, 2015
    可以的
    kaedea
        11
    kaedea  
       Oct 29, 2015
    再推送一次就撤销了
    finab
        12
    finab  
       Oct 29, 2015
    iOS 应该是再推送一条 BadgeNumber 设置为 0 吧。。
    就像应用自己设置 BadgeNumber 为 0 效果一样。
    推送就没了。。
    laoyur
        13
    laoyur  
       Oct 29, 2015 via Android
    @finab 那样只会把所有的 notification 都消掉
    我一直以为楼主和楼下讨论的都是消掉固定某条 push (not local),我以前调查过这个问题,是没有公开消掉某条 push 的接口的
    至于 5 楼的说法,抱歉我现在没有 iOS 设备,也无从验证,不知道是不是用的 badgenumber 0 的全消方式,还是其实用的是消掉某条 local
    11 楼的说法倒是第一次听到
    zongwan
        14
    zongwan  
       Oct 29, 2015
    iOS 可以取消特(自)定 type 的
    mudkip
        15
    mudkip  
       Oct 29, 2015
    QQ 等 app 都有这个功能
    没具体研究过,不过怀疑是发送一条 content-available 的 push ,然后启动 app 的后台来处理
    typcn
        16
    typcn  
       Oct 29, 2015
    收到推送之后,客户端是可以在后台启动并处理一下这个推送的。
    加一个特殊的 flag ,删推送
    vic2012
        17
    vic2012  
       Oct 29, 2015 via Android
    这并不是 iOS9 的新特性,至少在 iOS8 就可以实现了
    matsuijurina
        18
    matsuijurina  
       Oct 29, 2015 via iPad
    @typcn 正解。这是做 iBeacon 应用的必备技巧,否则冗余通知太多了。
    laoyur
        19
    laoyur  
       Oct 30, 2015
    谢谢楼上各位,找到文档了 http://stackoverflow.com/a/31450953

    大致流程是:启用“ Enable Background Modes ”,发的 push payload 中必须带有"content-available":1 ,然后 app 在后台 /未运行的时候就能通过 application:didReceiveRemoteNotification:fetchCompletionHandler:被唤醒, app 自己处理一下后,发一个 [local] notification 展示在 notification center 中,并带上 tag
    等下一条"content-available":1 的 push 到来时,再根据业务处理之前的 local notification ,比如消掉某条特定的 local 消息。

    很久没做 iOS ,没有注意到 API 有这种变化
    finab
        20
    finab  
       Oct 30, 2015
    @laoyur 学习了~
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2908 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 67ms · UTC 15:21 · PVG 23:21 · LAX 08:21 · JFK 11:21
    ♥ Do have faith in what you're doing.