ios - How to display only once same push notifications? -


i'm using push notifications on app, , didn't find way display once notifications have same content. possible ?

my code :

@uiapplicationmain class appdelegate: uiresponder, uiapplicationdelegate, uialertviewdelegate, gglinstanceiddelegate, gcmreceiverdelegate {      var window: uiwindow?     var gcmsenderid: string?     var registrationoptions = [string: anyobject]()      func application(application: uiapplication, didfinishlaunchingwithoptions launchoptions: [nsobject: anyobject]?) -> bool {          var configureerror:nserror?         gglcontext.sharedinstance().configurewitherror(&configureerror)         assert(configureerror == nil, "error configuring google services: \(configureerror)")         gcmsenderid = gglcontext.sharedinstance().configuration.gcmsenderid          uiapplication.sharedapplication().registerusernotificationsettings(uiusernotificationsettings(fortypes: [.alert, .badge, .sound], categories: [category]))         uiapplication.sharedapplication().registerforremotenotifications()          let gcmconfig = gcmconfig.defaultconfig()         gcmconfig.receiverdelegate = self         gcmservice.sharedinstance().startwithconfig(gcmconfig)          return true     }      func application(application: uiapplication, didregisterforremotenotificationswithdevicetoken devicetoken: nsdata) {         let instanceidconfig = gglinstanceidconfig.defaultconfig()         instanceidconfig.delegate = self         gglinstanceid.sharedinstance().startwithconfig(instanceidconfig)         registrationoptions = [kgglinstanceidregisterapnsoption:devicetoken,                                kgglinstanceidapnsservertypesandboxoption:true]         gglinstanceid.sharedinstance().tokenwithauthorizedentity(gcmsenderid,                                                                  scope: kgglinstanceidscopegcm, options: registrationoptions, handler: registrationhandler)     }      func application(application: uiapplication, didfailtoregisterforremotenotificationswitherror error: nserror) {         print(error.localizeddescription)     }      func application(application: uiapplication, didreceiveremotenotification userinfo: [nsobject : anyobject], fetchcompletionhandler completionhandler: (uibackgroundfetchresult) -> void) {         gcmservice.sharedinstance().appdidreceivemessage(userinfo)     }      func applicationdidenterbackground(application: uiapplication) {         // use method release shared resources, save user data, invalidate timers, , store enough application state information restore application current state in case terminated later.         // if application supports background execution, method called instead of applicationwillterminate: when user quits.         gcmservice.sharedinstance().disconnect()     }      func applicationdidbecomeactive(application: uiapplication) {         // restart tasks paused (or not yet started) while application inactive. if application in background, optionally refresh user interface.         gcmservice.sharedinstance().connectwithhandler({(error:nserror?) -> void in             if let error = error {                 print("could not connect gcm: \(error.localizeddescription)")             } else {                 print("connected gcm")             }         })     }      func ontokenrefresh() {         gglinstanceid.sharedinstance().tokenwithauthorizedentity(gcmsenderid, scope: kgglinstanceidscopegcm, options: registrationoptions, handler: registrationhandler)     }      func registrationhandler(registrationtoken: string!, error: nserror!) {         if(registrationtoken != nil) {             print(registrationtoken)         }else{             print("registration gcm failed error: \(error.localizeddescription)")         }     } } 

i'm using google cloud messaging push notification app

thank's in advance


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -