My app has two different features that can each schedule a local notification. They are both reminders, but for different things, and for different parts of the app. Is there a way to schedule 2 different actions for these? For example, clicking notification style 1 sends you to the first tab, clicking notification style 2 sends you to the 2nd tab?
Yes this is possible, just add a custom NSDictionary to the UILocalNotification userinfo property.
For example, add a type when you create the UILocalNotification:
myLocalnotification.userInfo = #{#"type" : #"openTab1"};
Then in the application:didReceiveLocalNotification: you could do:
if ([notification.userInfo[#"type"] isEqualToString:#"openTab1"]) {
// Your code to open tab1
}
UILocalNotifications supports the userInfo dictionary. You can add some information here to trigger the response you want. For instance you can create you own "action" dictionary:
#{ #"action" : #"open_tab_1"}
When you receive the notification you inspect the userInfo and check the action key and trigger the correct behavior by just checking the equality of 2 strings.
Related
I am able to send custom parameter along with custom event to firebase analytics in android using below method :-
Bundle bundle = new Bundle();
bundle.putString("Action", "Action Perform Android");
bundle.putString("Category", "CustomEvent Android");
bundle.putString("Label", "click me");
firebaseAnalytics.logEvent("Button_clicked", bundle);
Above method is working and we can see this event on firebase console.
Here are some event that event name is reserve and we can not use this name again to send event to Firebase analytics like notification_dismiss, notification_open etc. These predefined events are automatically collected by Firebase.
Now I want to send some custom parameter along with these above event.
For example when notification_open event fired, I want to add notification title as a custom parameter along with this event. How can we override notification_open event or how can we set notification title custom parameter along with this event in android?
There is no way to add custom parameters to events that are automatically sent. You will have to define your own event to add those parameters to.
Once you've done that, you can combine the standard and custom event in BigQuery, to get both the default and the custom parameters in a single report.
I have registered for push and local notifications with two action buttons: action1 and action2. Upon receiving the notification, I can see both and can also take action depending on the action id. However, one of my use cases requires me to hide one or both the action buttons before I schedule local notification. Can I do that at run-time?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
In this method I am registering for notifications with 2 action buttons.
I see that depending on context we can define variable number of action buttons. However, context is predefined and not user defined.
Register user notification with multiple categories as you required like category1 with two actions, category2 with no action, category3 with only one action.
When creation of local notification, Use a defined category as you required.
like this
notificationName.category = #"Category_identifier";
Consider something like the following example:
I have a library with books, books have a difficulty and genre.
Each book is an instance of some object and could be presented by a view controller (I.E. a collection view, where each cell is a book, of perhaps a detail view where only one book is displayed).
The data of these books can be updated in the background by some kind of synchronisation method. It is possible only one book is updated, or perhaps one genre.
I would like the classes (mostly the views) to receive a notification of updates. I would like these notifications to be pretty clear. So when all non-fiction books are updated this is what should be notified.
I could of course use separate notification names for each kind, but if we are talking about an entire library, a big collection view containing thousands of objects would mean registering too many observers. In this case the observer would perhaps choose to receive any notification on books, of maybe any of a genre.
What I am missing (or can't seem to figure out) in NSNotification is some kind of granularity to specify this need.
So in short:
Is there a way to tell NSNotification more specifically what kind of notifications I would like to receive/who to send it to?
Alternatively, can I attach an object to a notification? If so, I could model scope (like meta-data) of the notification in this object and let the receiver check this data.
Yes , you can do that, just specify your object and pack your meta-data in an dictionary and attach your notification as userInfo.and use this method to post notification :
- (void)postNotificationName:(NSString *)aName object:(id)anObject userInfo:(NSDictionary *)aUserInfo
then you can access your notification like :
- (void)handleNotification:(NSNotification *)noti{
NSDictionary *userInfo = [noti userInfo];
YourObject *object = [noti object];
}
There is a badge count of 0 present in information that is entered in a web page. The information is sent out as a remote notification and as a data stream through sync which creates a local notification.
When I receive the remote notification this is indicated by the fact that the badge key is set to 0.
The public documentation says this:
Key: badge, Value type: number; The number to display as the badge of
the application icon. If this property is absent, the badge is not
changed. To remove the badge, set the value of this property to 0.
When I receive this information through the sync and create a UILocalNotification for it, setting the applicationIconBadgeNumber to 0 means something entirely different.
The public documentation says this:
The default value is 0, which means "no change.” The application should use this property’s value to increment the current icon badge number, if any.
Also, the semantics differ a bit since you cannot make a property absent the same way you can with a key-value pair in a dictionary.
The question is, how do I compensate for this difference? I don't have any insight on how it works on the web server (backend), I can only see what is actually entered in the UI as far as badge count is concerned. I do notice that when it is received the 0 have different meanings. Should these differences be handled by the backend, or should I handle them in the client?
Is there any reason for these differences?
I am working on a custom email notification for a WSS 3.0 solution. I am using a custom class inheriting from IAlertNotifyHandler to generate the email. There is a great example here that shows how this is done for an Immediate alert. Here is some of the code related to the SPAlertHandlerParams, which is used to get information about the alert and the item that triggered the alert.
SPAlertHandlerParams ahp;
int id = ahp.eventData[0].itemId; //gets the itemId of the item triggering the notification.
SPListItem myItem = list.GetItembyId(id);
For immediate alerts, this works great as the item I want is always at the [0] position of the eventData object. For a digest event, I thought I could just loop through all of the items in the ahp.eventData. Two problems with this.
First, it gives me all of the events where it is sending notifications, not just the ones for me. Second the eventData[0].itemId no longer points to a valid id on the list. It is 6-7 digit number instead of a 3 digit number.
Does anyone know the correct way to get to the alert information for digest emails?
Please let me know if you have any additional questions about this.
Thanks for your help!
For my project, I created a custom timer job (using the post by Andrew Connell) that mimics the Alert functionality. It runs overnight and queries for any users subscribed to my list with daily alerts. It then packages all of the new tasks into a custom email message.
I left the custom alert in place to suppress any daily notifications from the system. I just return 'True' so that alerts are not sent for tasks assigned to only 1 person. I suppose looking back on this, I could have run the query code in the custom alert and not need a separate timer job.