Use push notifications also if user doesn't accept them - objective-c

I have a doubt about iPhone push notifications. I need to use them when the user is using the app, but for me aren't necessary alert-sound-badge when the app is closed.
My question is: could I use these kind of notifications also if the user doesn't accept the push notifications when the app starts?
I would to use the push system to avoid any timer to get periodically info from our server when the app is running; they will be custom notifications with no alert, no badge and no sound.
Thank you

No, you can't circumvent the user's choice (the user said no, you should respect that). However, you can determine if the user opted out using
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types == UIRemoteNotificationTypeNone) {
// user does not want to get push notifications
}

No you can't. If user refuses the notifications, APNS server will not send them to the device.
And by the way, trying to get application / user info from an app without asking for user permission may lead to application rejection from the App Store.

Related

Is there a way where i can NOT send push notifications depending on payload?

Context:
So i have an app which sends reminder notification depending on user's preferred time.
I dont want to send notification if user's app is already open or running.
we are currently using react-native-notifications and of course #react-native-firebase/messaging.

IOS UILocalNotifications live after my app has been deleted...how to deal with these notifications?

I was wondering how to deal with UILocalNotifications that were created using my app but the app then got deleted.
Lets say that after creating a few notifications, the user decides to delete the app, but i've noticed that even though the app is deleted the notifications lived and they still fire in the correct time, but this doesn't make sense to me since the app is not existant in the phone anymore.
I understand how this is possible, but i would like to know if there a way to delete such notifications when the user decides to get rid of my app?
And does this happen as well if the app is being updated?
Thanks.
Another way is to use APNS (remote notifications) instead of local notifications.
This way, once your App was removed, pushed notifications will not get to the device anymore , nor to the user's attention.
At this stage you can be aware of the App's removal (using APNS feedback service) and cease your sending mechanism for that user (his push token..)

Friend request real time notification to recipient device

I want to notify a user if any other user wants to be friend with him. The only ways I can currently think of is notify through push notifications or recipients device will keep polling server for new information at certain frequency or device will check for new information only when it launches.
I have some problems with Push Notifications method to send requests
If device is offline only last notification will get processed
If app is not running, push notification will get delivered in Notifications and I don't know how can I extract information from there to my app.
Also, if device keeps polling for new information number of API calls will be very high which is not cost effective and alternately if device asks for new information only at start up launch it will not get real time updates.
Is there any way I can send information to device as soon as information is available?.
Any suggestions will be appreciated
Have you taken a look at Urban Airship?
They have a great framework set up for queueing and receiving push notifications, even when your app is offline. You can either queue the notification from the app itself or from your server hosting your account data. They also have the ability to compose and push rich content notifications.
The basic account for small apps gets 1 million free push notifications per month. Everything beyond that is fractions of a penny.
Hope this helps, Cheers!
Notifications is one such thing which can drain down battery if one takes polling route, thats one of the reasons Apple developed Push Notifications. I would recommend try to use Apple Push notification as much as possible as it would have been optimized to hell. If you have different flows for when the app is active & for when the app is not active (reg. notifications) you can do it like so -
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
if(application.applicationState == UIApplicationStateActive) {
// app active.
}
else {
// app not active
}
}
But if in any case Apples Technology does not suite ones needs one could always use third party services. In this case there are a few that can really help you.
Pusher has an Objective-C library and a REST API (along with a number of libraries) that would let you push realtime updates from your server into an iOS application.
OpenPush is another such service. Also check this link, here's a compiled list of realtime technologies in which I'm sure you'll also find technologies that meet your requirements.
All of these are better than polling.
Is there any way I can send information to device as soon as information is available?. Any suggestions will be appreciated
user1 wants to add user2 as friend.
from device, post information to server, in your webscript, process the friend request of user1 to user2 (insert/update information to database etc), when done. send the notification to user2. this will work if the device is offline, user2 will have real time update, if the app is running. you can run scheduled request that will check new notifications. say every 2 minutes, a method in your app runs. but thats not a very good idea. A reload button inside the app to check notification is better.
What you would normally do is to use the push request as a means of informing your app that new data is available. The user clicks on the push notification - the app is opened with the
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
you register that there was push, query your server and the server let's your app know that this list of new friend requests are there.
You can't really do the queuing of messages on the device - and you don't need to. It's much easier to just store the info on your server until the app queries it.

iOS Push Notifications to specific user in the same deviceToken

I am using Urban Airship to test push notification and it went well.
My problem is how do I specify which user to get the notification not just the device token.
I mean in some situations where one device has multiple users, so many users registered the same device token to server.
Or do I have to do the filter on the device (client side) itself?
There's no real way to do what you want unfortunately. In APNS there's only such thing as a device. You push a device and it shows a message / badge / sound on that device.
If your app can have multiple users associated with it then you'd need to work out from the push which user it relates to and handle it accordingly. How you do that would depend on your app but you could add in a custom key to the push which indicated the user it's for.
If your app only ever has one user logged in at once then I suggest that when you hand the push token to your server, the server first turns off push for the user that the token was originally registered for and subsequently turns push on for the new user.

How does push work on ipod touch with respect to auth credentials?

I installed this instant messenger program called IM+ that keeps your accounts online even when you exit the application (you know... touch: only one app at a time) it accepts push deliveries to report you have a message.
I am kind of puzzled on how they can keep me logged in and send me a push notification that someone is messaging me. I noted the same happens for mail. If I receive a mail, even if I don't have mail open, a badge appears near the icon.
My main concern is the password. How does push work? does it mean that apple or the company behind IM+ stores my email and instant messenger passwords to keep me logged in and push me a notification when I have something new ?
Edit: ok... the tumbleweed is a bit too much for such a question.
Read this to understand how it works: Apple Push Notification Service