I have quite silly question: how to send notifications?
For example, when I register user on my app, I want to welcome him/her with
notification.
Assuming you're using Facebooker (which, really, you should be), you can create a Publisher class.
You can also use facebook_session.send_notification([user_fb_id], "notification message") (in your controller). This will be an app-to-user notification, and you have a limited number that you can send to users each week.
To see this limit you can use the following call:
Facebooker::Session.create.post('facebook.admin.getAllocation', :integration_point_name => 'announcement_notifications_per_week')
Related
I'm building an iOS app that needs to have notifications display every time any user of that app does something like send another user a message. What I have currently is a working Ruby on Rails and Android app. The Rails app notifies Firebase when a notifiable activity occurs like so:
if active_time.save
fcm = FCM.new("AIzaSyDhMXi3797t2oZMxOTo-Nph8IoypRL8Ooc")
registration_ids = Array.new
for user in group.users do
if not user.token.nil?
registration_ids.push(user.token)
end
end
options = {data: {score: "123"}, notification: {body:"Active time added to " + group.name, title: "Groupsync"}}
response = fcm.send(registration_ids, options)
active_time.delay(run_at: active_time.start.getutc).send_group_live_notification
What I'm unsure about is how to get my iOS client to notice these activities and display notifications like its Android counterpart. I have set up FCM on the iOS client and am able to send notifications, just not sure what the next step is in terms of making the link.
EDIT: I should mention for the above piece of is controlled by my iOS client through HTTP POST requests
I recommend you using a service line OneSignal. It's free and you can set a lot of platforms there, between android, ios and web browsers. For ios you're gonna need a push certificate from apple (see more here: https://medium.com/#ankushaggarwal/generate-apns-certificate-for-ios-push-notifications-85e4a917d522). Once you set your configs for android and ios, for example, you can use their api and send the notifications using their ruby gem, for example (https://github.com/tbalthazar/onesignal-ruby).
Good luck!
If I have sent a few messages in my iMessage app and I want to access previous messages (obviously just my own app-created messages, not just any messages the users have sent in their conversation), is there a way I can do that?
I can access the most previous message with this:
[self activeConversation].selectedMessage;
Any way to loop through previous messages that might not have even ever been clicked by the user (so simply storing it in user defaults is not an option)
There is no way to do this. Apple considers this to be a security/privacy issue.
I need to send a message in slack at a time set in advance.
Is there a way to do it through the Slack API or do I need to have a script running and checking if it's time to send the message and then send it?
You should be able to create a reminder sending a message to #slackbot
The message should be like:
/remind [#someone or #channel] [what] [when]
Here's some examples:
/remind #username to do something in 24 hours
or:
/remind #username to do something at 16:00
You can use this free Slack application to send scheduled and self-destruct messages.
https://timy.website
Sending a scheduled message
/send Happy birthday at 12am
/send Happy birthday in 1h30m
Sending a self-destruct message
/delete Secret message! at 2pm
/delete Secret message! in 3h
You can find more details on the website.
If you just want to send a short message to a user at a given time you can use the build-in reminder. The reminder.add method allows you to specify a date, time, message text and the user to receive the message.
The reminder message will appear in the "Slackbot" channel of the addressed user.
Here is an example on how it would look like:
Update April 2019:
There is now a new API method that allows you to submit message for later sending. Its called chat.scheduleMessage.
You can use the official slack api at endpoint chat.postMessage with a key post_at to have your message scheduled. More information in official slack documentation https://api.slack.com/messaging/scheduling. You can also use 3rd party applications, which are free most of the time, for example https://thetopchat.com/ and schedule your message with commands like, for example:
/delay in 3 hours {your message here}
or
/schedule tomorrow at 3pm {your message here}
The Slack API now provides a dedicated endpoint for that. You will need the chat:write scope and the docs say:
Schedules a message to be sent to a channel.
I just implemented it and works as expected.
You can check the docs here: chat.scheduleMessage
I am working on sending SMS demo. I want to send how to send the SMS and how to set the delegate to MessageComposeViewController. and in order to send the message we have below line
[self presentViewController:messageController animated:NO completion:nil];
This line will present the MessageComposeView on screen with SEND button. And Once we click on send button it sends the message. What I want is to send the message directly without presenting this MessageController on screen. Please help how can I do this.
In this related question, Apple has restrictions in place on being able to send a SMS message without the user clicking the SEND button.
Apple really wants the user to be in control of the SMS functionality of their phone. Otherwise all sorts of data could be flying off some random app (e.g. spamming your contacts with "try this app out!", which would not be very friendly nor very nice).
One of the answers in this question does have a potential non-MFMessageComposeViewController solution, however I have a feeling that if Apple catches you doing this they might deny your app from being approved for the app store.
You could send the message using some webservice on the internet. http://client.suresms.com/ProjectInfo.aspx?Info=3 or www.clickatell.com. They have bunches of API for sending messages.
In SureSMS simply create an account and make a http request to
http://suresms.com/Script/GlobalSendSMS.aspx?login=[youraccountnumber]&password=[yourpassword]&to=[phonenumber]&Text=Hallo.
Remember to URL encode the message text and use countrycodes. Thats it.
You have to present MessageComposeViewController.It's not possible to send without presenting it.
MFMessageComposeViewController has delegate method while delete/send/save. which only perform while we present it.
(void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
You can't do it without MFMessageComposeViewController. Apple won't allow to send SMS without user interaction.
As per document
You must not modify the view hierarchy presented by this view
controller. You can, however, customize the appearance of the
interface using the UIAppearance protocol.
I've alternate solution of this, Alternative way can be Using web service API. Create a web service at server side that send a message to specific number(s) that accept numbers as parameters with request.(according to your requirement)
As using Web server or external sms provider can do it.
It is NOT possible . Apple willn't accept your App. Apple will reject your App if you do like that. Human interface guidelines should be followed up.
Starting with iOS 5, there are two notification styles: banner and alert (the "old" style). A user can set which style to use for each application in the settings. However, the default now seems to be that notifications are displayed banner style.
I'm using local notifications for reminders about events that will happen "now". A banner disappears shortly after it appeared (and it's not obvious enough that one can tap it), so for these notifications it would be desirable to have the alert style notifications as those stay on screen until the user decided on an action (ignore or go to app).
Is there a way either through code or for example Info.plist entries to tell iOS that the alert style notifications should be used by default (as long as the user hasn't configured something else)?
Update: The absence of information/documentation is not enough for me to have this settled. I want either something like a forum/blog post from someone with authority (Apple employee or someone along the lines of Erica Sadun) saying it's not possible, or if it is possible then I want the solution. A workaround like "ask the user to change the setting" isn't good enough either.
I would like to add something, since I've opened a TSI and somehow I asked about this and have been answered. From Quinn "The Eskimo!":
"This depends on you mean. You have some control over how the notification appears based on how you set the UILocalNotification properties (things like alertBody, soundName, and so on). However, if you're asking about the way in which those properties are interpreted (the things the user can customise in Settings > Notifications), those are user preferences and not exposed via any API."
I have an alarm app for which I also need this functionality. Under iOS5 if the user is using another app when it goes off then the banner appears. Consequently I spent a lot of time browsing for a solution.
However, it's not possible to control the style of alert generated by a UILocalNotification I'm afraid :(
You can see from the class reference that there's no provision for it:
http://developer.apple.com/library/IOs/#documentation/iPhone/Reference/UILocalNotification_Class/Reference/Reference.html
Or in the plist:
http://developer.apple.com/library/ios/#documentation/general/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html
Best thing to do is tell the user what to do to change the settings.
You probably won't find 'authoritative' from your peers here, you should better ask directly to Apple; and the question has already been asked several times on theirs forums and not answered...
The HIG programming guide - http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/MobileHIG/TechnologyUsage/TechnologyUsage.html#//apple_ref/doc/uid/TP40006556-CH18-SW1 -
"iOS apps that support local or push notifications can participate in
Notification Center in various ways, depending on the user’s
preferences."
That last sentence is the only 'authoritative hint' i found.
The USER'S preferences <= you can't force the user ('s preferences).
Period.
This design choice is clearly the Apple Way (applications' playground IS limited, to ensure the best user experience possible)
As for more authority... maybe shouting ?
NO YOU CAN'T CHOOSE YOUR NOTIFICATIONS DISPLAY STYLE, IT'S THE USER'S CHOICE
Just kidding...
Anyway, a workaround might be to provide a way in your application - hint/ tutorial - to push the user to change the alert style himself...
good luck !
Obviously you don't like hearing no for an answer, but, no.
You can use this line to query the current settings for notification style:
UIRemoteNotificationType* enabledTypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
You can check the enabledTypes and then instruct the user to change the notification style in the settings.
have you tried
[[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
in your didFinishLaunching method, this won't help those updating but should enable alerts for those first installing