I'd like to know if it is possible to send a push notification, through APNS, without displaying a notification if the application isn't started? (in this case, the message received will be thrown away)
Thx
I may be misunderstanding your question, but I am assuming you are asking how to provide the user with options to turn off particular aspects of the push notification?
You will have to set this in the App. That is, if the user wishes to turn off this particular aspect, your App will have to send up the request for them.
- (void)registerForRemoteNotificationTypes:(UIRemoteNotificationType)types
So, if you still wanted to do badges, but no longer show alerts:
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge];
Don't forget to resend the Token to your provider as it may have changed after this request.
Related
I have the following problem.
I look for a capability to delete a push notification from a device (iPhone respectively Apple Watch) but this device have receive the push notification.
The use case is that a USER A send a request to all available USER Bs. A push notification is send to all these USER Bs. At the moment the push notification arrive it will shown on their Apple Watch. One of the USER Bs answer that he accept this request. After he press the button to accept the request the notification should be deleted on all the other devices.
I really do not know a capability to do this.
But I know that you can handle this problem in Android as provide a unique ID for this notification. After that you can delete the other notifications with this particular ID.
Is their maybe a same way for iOS like it is provided in Android?
This doesn't really have anything to do with WatchKit/Apple Watch.
To answer your main question: no, you can't do this as it describe. Once you fire off a notification, it's in the user's hands to decide what they want to do with it.
As an alternative, you could maintain an "inbox" with every notification in your app and use the notification to prompt the user to check it. That way you could remove a notification from the inbox on the server side of things.
I am not a developer as much as i am a project manager, i need to know more if the following is possible to help me decide the future of a project.
mainly my question is, can i trigger a certain method (function) in my application using the push notification ? so my app might be in the background (or not) and i want to send a push notification message that wakes the application and execute some piece of code.
if the answer is yes, can this be done without the user interaction ? so i mean without the user clicking on the push message ? to be some kind of automated, so i send the Push notification message, the iPhone receives it and execute the code, without the use interaction ?
i can set up my own APNS server if needed.
i am not looking for a code as much as i am looking for an answer if this can be done or not.
Thanks,
Yes, this is possible, as long as the user clicks on the notification. This could be done either with local notifications, or push notifications.
When an application is launched in response to a notification, the AppDelegate method application:didFinishLaunchingWithOptions: will have an option indicating the notification that precipitated the launch.
It cannot, to my knowledge, be achieved without user interaction.
I'm just trying to understand push notification more.
Let's say I have a web service that my app connects to that needs a user to sign in with a username and password. And this all works fine when running the app.
Now... how does the web service determine which user to send the push notification to?
I'm really unsure on how it works with users with usernames and passwords. It would be great if someone could enlighten me to this. A better understanding could improve my apps in the future. Thanks!
I'll give a brief over view of how push notifications work:
First, your app will call the registerForRemoteNotificationTypes: method. This will check that your app is allowed to send and receive the types of notifications you requested, and contact Apple's servers to register your device. You will get back a special token used to uniquely identify the device.
Your app needs to send this token to your server along with the details of the account that the user is logged in with, so your server can associate that token with the user.
When you want to send a push notification to a user, you lookup the token you received previously for that user and use that when sending the notification to Apple's server. This will forward the notification to the appropriate device.
It's probably a good idea if you read the Apple documentation here: Apple Push Notification Service. This will give you a clearer understand of how it all works.
Here is the wonderful tutorial explains in detail, http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12
For login procedures, you don't even need push notifications. If you need a general introduction, you will find one here
Below I have mentioned 2 links.
https://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html
http://mobiforge.com/developing/story/programming-apple-push-notification-services
Now coming to your question, push notification is pushed from a server. Now for a particular user the server side should maintain the database such that whatever changes made to a specific user should be pushed to that device id.
Hope this help.
Push notification is awesome feature of iOS apps. It works like your application needs to register for Push notification as
//Your application registeres for push notification using following line
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
This will tells you application to handle generation of device token failure/success by delegate methods
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
//Your application registered for push notification i.e. allowed by user.
//You need to take device token and pass it to your webservice and store it in database.
}
- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
//Your application registered for push notification i.e. not allowed by user.
}
So, Now what after you have device token ? .. Its simple now use it for sending push notification. You can find different code for that using PHP as well as .Net. Search around and you will get plenty of them.
On iOS5, the push notification shows on the top bar and not block user. When the push notification is showing and user click our application but not the push bar, our app will launch normally. However, we want to cancel the push notification at that time. Is it possible ? Thanks a lot!
Short answer: No. There is no way you can manipulate sent notifications as far as I know.
Slightly longer answer:
Once a push request has been sent to the Apple Push Notification servers, thats it. It disappears into their system and they will then try to deliver it on a 'best effort' basis. You receive no feedback about its status or any ability to change/delete it.
The only form of feedback you can get is about which devices do not wish to receive push notifications that you tried to send to.
If you want to send delayed notifications which can be cancelled/modified at later data, either write you own solution, or use some pre-existing solution (e.g Urban Airship).
I am building an app that uses the fine Urban Airship api to send the user push notifications.
The app keeps track of event dates that are added to the app by the user.
This means I have no server in place for dealing with push, the app itself simply
schedules a push notification with Urban AS when the user add the event date and time.
If the user decides to delete the event before it occurs I un-schedule it with Urban AS. All is good. I, however, would like to not send notifications to a user that has disabled notifications as these notifications are no free:)
I know the Push Notification API from Apple makes sure the user will not receive any notification if they turned them off in settings. They will simply ignore the scheduled notifications Urban AS sends, which is a waste of bandwidth and money.
How can I tell if the user has disabled the notification for my app?
Also, I see no other option than to test if the user has turned off notification and then tell Urban AS to cancel all notifications and if the user turns them back on, I will have to go through all events and re-scheduled them :/ each time the app runs.
Can anyone think of a way for me not to have to fill up my appDelegate with all kinds of conditional code for testing these scenarios? e.g. user has turned off push since last running the app, user has turned them on since last time. I am also concerned if the user will understand this behavior?
Guess I am just asking for a bit of best practice with this push / Urban Airship setup:)
Thanks.
As I see it, [[UIApplication sharedApplication] enabledRemoteNotificationTypes] will return the notification types the user has currently enabled for your app.
Otherwise, you are correct. You have to call this method on every app launch and, in the case that the user has reenabled notifications, reschedule all events that you had formerly deleted.
As to the question of filling up your app delegate with all kinds of conditionals, you might want to write a separate PushNotificationsController (not a UIViewController, just a NSObject subclass) that will handle all push-related stuff.