Push Notifications && device identification

Discussion in 'iOS Programming' started by DennisBlah, Oct 2, 2014.

  1. DennisBlah, Oct 2, 2014
    Last edited: Oct 2, 2014

    DennisBlah macrumors 6502

    DennisBlah

    Joined:
    Dec 5, 2013
    Location:
    The Netherlands
    #1
    Hi all,
    currently working on push notifications.
    I want to send push notifications to users, but I'm facing 2 little problems.

    1) How can I send push notification to ALL users of my app?

    2) How can I identify a device? Because I store tokens into database, and update if needed, but then I need a unique number. To know which record to update.

    Ofcourse I can generate some number, store locally on device and hope its 100% unique. like random(1000) * timestamp
    Code:
    [[NSUUID UUID] UUIDString]
    
    gives me a different result every time.
     
  2. TheWatchfulOne macrumors 6502

    TheWatchfulOne

    Joined:
    Jun 19, 2009
    #2
    Can you be more specific?

    Do you want to send local notifications or remote notifications?

    What do you have that would prevent some users from receiving notifications while allowing others to receive notifications? Other than the fact that users can opt out of receiving notifications.

    What kind of info will the notifications contain? Knowing this would help somebody to know how to help you with regard to how and/or when to send them.

    It used to be that developers could use UDID to identify a specific device but that is now not allowed. How specifically do you want to identify the device? Do you want to distinguish iPhones from iPads or do you want to distinguish one iPhone from another of the same model and generation?
     
  3. DennisBlah thread starter macrumors 6502

    DennisBlah

    Joined:
    Dec 5, 2013
    Location:
    The Netherlands
    #3
    Hi TheWatchFullOne,

    Eventually Im going to send remote and local notifications, but for now only remote.

    These notifications will contain different messages. Its to notify the users that do want to receive notifications about new events that coming up. (Its for an app for concert events company)

    The thing is I want to know difference of the devices. Once a device's token is changed, i dont want to keep the old token but update the old one.

    About sending it to all users, i could write a loop that will go through all tokens and send it one by one, but I think it should be able to simply send it to all users in one go.

    Is it also possible to link a notification to a specific view? When you click on my notification it will go to the main view of the app. I would like to have it to go to the view where this new event is described.

    Thanks for any help!
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    The Local and Remote Notification Programming Guide talks about these things:

    Make sure you've read the whole thing and then come back here with specific questions, if you don't understand something.
     
  5. DennisBlah thread starter macrumors 6502

    DennisBlah

    Joined:
    Dec 5, 2013
    Location:
    The Netherlands
    #5
    Hi dejo

    Thanks for pointing to the documentation.
    I understand the part about sending big amount of notifications, however I only have 1 webserver, and dont know how to send through multiple gateways. I will be sending the notifications with a delay between each token.

    Then still I cant find any way to get a static unique number from an device. I guess generating a unique number and storing locally will be the only solution for me.

    Pointing to failing notification multiple times to the advice to remove the token from the database is an good idea.

    I only got one more question left

    The didReceiveRemoteNotification, is that being triggered when it actually receives it?
    I would like to tray to fetch content of the notification where the user clicks on, so by parsing that content I could be able to redirect to the viewcontroller I want the user to see when they click on it.

    Any idea's?
     
  6. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    Yes! Try it and see!

    Look at the userInfo NSDictionary that is passed in this method.
     
  7. DennisBlah thread starter macrumors 6502

    DennisBlah

    Joined:
    Dec 5, 2013
    Location:
    The Netherlands
    #7
    I will :)

    Thanks for the tips and hints ;-)
    I guess I will be able to trigger different actions with
    Code:
    application:handleActionWithIdentifier:forRemoteNotification:completionHandler:
    
    and the Item ID of the framedata from the notification :)

    Thanks again!!
     

Share This Page