iOS custom push notification via Notification Service Extension - ios

I am stuck with custom push notification. What I am looking to acheive is to have image in notification. For that, the following things has been done:
Created Notification Service Extension
Enabled App groups and push notification in both- app and notification extension.
Trying to build app, but unable to install on iPhone with the error:
having same bundle id in app and extension
Do I need to create separate bundle id and provisioning profiles for Notification Extension? If yes then how notification service class methods will be called?
Waiting for your early response. Thank You.
Expectation- Need to implement custom push notification

The Notification Service Extension is defined as a target in you project settings, hence it needs a unique identifier different than your app's id. It's recommended that you format the extension's id like so: App_Bundle_Id.NotificationServiceExtension
Bundle Identifiers are unrelated to the method calls, iOS will handle them for you. Whenever a device receives a push notification, the extension is called (if configured properly) so you can execute your logic.

Related

iOS Push notification service extension bundle id

I am confused why there should be a separate bundle id for the notification service. But, since that the case should the push notification enabled in both the app id and the notification id?
Should the Add groups be enabled too?
After that, when to use notifications provisioning profile created for notification id and when to use the ones created for the app id?

Is it possible to modify incoming Push Notification Text on iOS

I have a usecase where a notification provider ends up sending me push notification text in a format that I'd like to change. Can I do so in the app's ObjectiveC/Swift code?
Since iOS 10, it is possible to modify the text of push notifications (unless they are silent notifications) by creating a UNNotificationServiceExtension for your application.
The extension is created as a separate Target in Xcode and provides a NotificationService class with two functions, one that allows you to modify the content of the push notification (didReceive withContentHandler) and one that notifies your application if didReceive withContentHandler did not complete in time (serviceExtensionTimeWillExpire).
For this to work, the push notification that is sent to your application also needs to be modified to include the key/value pair mutable-content with a value of 1 so that iOS knows to invoke the UNNotificationServiceExtension for your application.
Apple's UNNotificationServiceExtension Documentation
Your iOS app does not get a chance to modify the incoming push notification data before it is displayed to the user.
No you can't change the notification alert message(text), which user will see when app is not in foreground state. The use will see the same text what the notification payload contains.

Does Gmail Project Support only one push notification

I created one project and did all the steps required for push notification creating topic,subs and all but when I call watch method will it work for who I have created the project or for any user who i give in watch method
The user the access token you are using corresponds to when calling the watch-method, is the one you will get push notifications for.

How don't allow iOS to start application when specific type of push notification arrives?

I want PHP server send to my iOS application two types of push notifications:
New income message. For this push I want iOS start my application if it was suspended, show badge, play sound, etc.
New friend request. I don't want this push to start my application and I only want to handle if the app is in the foreground.
How can I achieve this? How can I handle different push notifications differently?
I'm not sure if it will work, but you should try for your 2nd scenario to send a notification that contains only custom properties. In this case there will be no alert to display, sound to play nor badge to update, so I think this notification will only reach your app if it's already running.
For the 1st scenario, send a notification with pre-defined properties (alert, sound, badge).
Application-side handling for remote notifications should start with the method in the application delegate protocol application:didReceiveRemoteNotification:.
However, in order to avoid the application launching in the first place, you need to make sure the PHP server crafted notification doesn't offer the option to launch the application.
See the documentation on the Apple Push Notification Service here:
http://developer.apple.com/library/ios/#DOCUMENTATION/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW9
In particular, you want to focus on the content of the aps dictionary as documented in The Notification Payload section. The aps dictionary received can badge your application's icon without opening the app at all.

How to start an iOS push notification from an in-app process

I'm building an app that plugs into a third-party service that will send messages to the iOS device. So far I've been unable to find any documentation on then starting off a push notification when the delegate method is fired to say that a new message has been received.
So far, I've got the app registering to receive push notifications and the delegate method firing, I'm just not sure how to connect the two together?
The app will have a minimum deployment of iOS 5.1 if that helps.
This is not how remote notifications work. Their main purpose is to notify application about some event. So application only receives remote notifications and note send them. So scenario is:
App is notified via
application:didReceiveRemoteNotification: //if running
or
application:didFinishLaunchingWithOptions: //if closed
According to notification payload you determine what exact action you need to perform. For example notification says that a new message was sent to the user. Then you need to send your custom request to the your server and get that new message.
I've discovered that in this case it is not push notifications that I want but local notifications instead.

Resources