RESEARCH SYNTHESIS
15 Growing Traction and Improving
Retention In this chapter, you will learn about traction, the proof that somebody wants to use your product and, in most cases, is willing to pay for it, resulting in a profitable business in the end. Now that we have obtained some actionable metrics, as we have learned in the previous chapter, we will see how to grow traction. Without sufficient retention (returning users to your app) or too much churn (users abandoning your app), the moment of truth will be gone quickly and we will lose traction. Let's investigate how we can increase the retention rate. Also, we will see what we can do the keep the churn rate low.
Specifically, in this chapter we will cover the following topics:
Learning about the definition of traction Finding out how we can grow traction and when "growth hacking" comes into play Seeing how we can improve retention Learning how to stay in touch with your app users Seeing what it takes to implement a notification mechanism to remind users
Drongelen, Mike van, et al. Lean Mobile App Development, Packt Publishing, Limited, 2017. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/harrisburg-ebooks/detail.action?docID=5165112. Created from harrisburg-ebooks on 2020-12-01 07:19:37.
C o p yr
ig h t ©
2 0 1 7 . P
a ck
t P
u b lis
h in
g , L im
ite d . A
ll ri g h ts
r e se
rv e d .
Growing Traction and Improving Retention Chapter 15
[ 218 ]
Traction So, what is traction? Basically, it is about upcoming patterns that indicate a scaling and repeatable business. Traction is an evidence of a sufficiently large market demand and more specifically about adoption and engagement. If you do well, traction is the confirmation of the hypotheses that you have about your product or service. Traction is about making actual progress and it is important in each phase of your app. It is about the first few early adopters that sign up when you just got started, and eventually it also is about the users that make (in-app) purchases. How well is your app doing converting people into users and users into customers?
Even emerging app clones (or copycats) are a sign of traction. It proves, along with your grown user base, that the problem that your app is solving really matters and that the problem is worth solving.
Things as profitability (revenues), the number of registered and active users (retention), engagement, traffic, and even partnerships are all things that you can use to measure traction. Be aware that isolated information is no real proof for traction. For example, you can run some campaigns to grow your user base but if the Customer Acquisition Cost (CAC) is higher than the Average Revenue Per User (ARPU) then it makes no sense to look only at the revenue to determine traction. You need to make sure that the Lifetime Customer Value (LTV) will be higher than the cost of onboarding new users. You need to lower the cost or you need to increase the LTV. To do the latter you can, for example, consider offering subscriptions. Other than one-time in-app purchases, it will lead to recurring revenue.
Working on the scalability of your apps, business will help to get and improve traction. However, to understand how this will work for your app, you will often need to do stuff that does not (yet) scale, as we have seen in Chapter 11, Onboarding and Registration. You first have to learn what works and what does not. The "concierge service" has been mentioned earlier and it is something that definitely does not scale. However, it could help you obtain a lot of useful insights. Other things that you can do include cold canvassing and networking in general. Since these strategies are things that business-oriented people love to do, but most developers will hate, we will examine what else there is that we can do to grow traction.
There are a couple of things that you can do to improve awareness for your app and to find your early adopters. If people see your app listed on any of the following sites mentioned and decide to download your app, then you will see the first signs of traction.
Drongelen, Mike van, et al. Lean Mobile App Development, Packt Publishing, Limited, 2017. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/harrisburg-ebooks/detail.action?docID=5165112. Created from harrisburg-ebooks on 2020-12-01 07:19:37.
C o p yr
ig h t ©
2 0 1 7 . P
a ck
t P
u b lis
h in
g , L im
ite d . A
ll ri g h ts
r e se
rv e d .
Growing Traction and Improving Retention Chapter 15
[ 219 ]
In addition to writing posts about your app on Facebook, LinkedIn, and Twitter, here are some places to get started:
Product hunt: https:/ / www. producthunt. com Betali.st: http://Betali.st Start-up list: http://startupli.st Reddit startups: https://www.reddit.com/r/startups
These are the places where your (potential) early adopters are, people who are curious to learn about new apps and services. Since they love giving feedback about new products, these are exactly the people what you are looking for.
Of course, you should have a blog about your app (if not, start one right now), way before the first (beta) version of your app is launched. It is important to build an audience first before putting any effort into developing an app. Make sure that you have a clear call to action for the readers of your blog. Make it as convenient as possible to sign up for your email newsletter and send those newsletters on a regular basis to your subscribers. Once your app is out, continue your blogging and do some experiments (split testing for your email) to see what leads to the best conversion (from reading to opening your app, landing page and downloading, and using your app).
Freemium or premium only? Some say that the only relevant traction is price traction. If your app is completely free the demand for your app can be infinite. However, that alone is not really important if there is no revenue. Asking money for your app right from the beginning is the ultimate way to measure traction. The earlier you generate revenue, the faster you validate the app concept. If you think this approach won't work, think again and have a look at the various crowdfunding sites on the net. Of course, you need to have an awesome story about your app. You need to tell them what is so great about your app, but you already have a great story, right?
No business will survive without any income. In fact, a free app does not exist. The money has to come from somewhere. Offering in-app purchases is one way to monetize your app, but only a small amount of users (2% or less) will really do so. The other 98% will continue to use your app without ever paying for it. The freemium models work because hosting is inexpensive and because you can scale your app without too much effort. However, you still need to pay attention to the full 100% of the user group. You have to respond to their reviews and you have to keep posting on social media. That can be very time-consuming. The income from 2% of your users should cover the cost for that.
Drongelen, Mike van, et al. Lean Mobile App Development, Packt Publishing, Limited, 2017. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/harrisburg-ebooks/detail.action?docID=5165112. Created from harrisburg-ebooks on 2020-12-01 07:19:37.
C o p yr
ig h t ©
2 0 1 7 . P
a ck
t P
u b lis
h in
g , L im
ite d . A
ll ri g h ts
r e se
rv e d .
Growing Traction and Improving Retention Chapter 15
[ 220 ]
It can be difficult to decide what features should come with the paid variant of the app. You need to have a clear understanding of how valuable each part of your app is for your users. Also, you can decide to offer a premium app only. If you charge directly from the start for your app, you will raise the barrier, but your sales numbers will be a real proof of traction. In Chapter 17, Monetization and Pricing Strategy, about monetization, we will have a closer look at price strategies.
There are, of course, others ways to monetize your app. You can think of showing advertisements. Also, you can also think of a solution that utilizes the web and mobile channels. Do not think of your app as the product any longer, but think of your app as a channel for your service. So, you offer your app for free, but, on the web you ask your users for money for subscribing to your service. That approach works very well for business- oriented solutions in particular. The revenues will be higher, probably because the perceived value of an app alone is likely to be lower. It is just a matter of perception but perception is important when it comes to marketing. It may also have to do with the fact that, often, people are less willing to pay for an app running on a smaller device. This is a bit silly but nevertheless, it is true. Perhaps we can focus on developing apps for large TVs only? I am just kidding of course.
From the perspective of a developer, it makes no sense at all. Developers know that it takes the same amount of work and that the size of a device does not matter here. Anyway, the perceived value and the channels you use do matter. They will have an impact on the amount of traction and how it will be determined.
Without clear objectives, you cannot measure traction or any other kind of success. The more abstract your goals are, the more difficult it will be to perceive the outcome clearly. To make the outcome measurable (actionable metrics), you need to define clear goals. Clear goals come with numbers, such as how many new signups (1,000?) do we want to have in a particular amount of time (1 month?), or how many emails do we have to send to grow the conversion of our users by 25%?
Improving retention Mobile app retention and engagement are metrics that can be an indication of your app's success. High app retention and engagement ratios often are a reason for your app's success. Retention says something about how often your users relaunch your app within a particular amount of time. Engagement is an indicator of activity. It says something about what they are doing while using your app, and how long and how often they are doing this within a particular session. Probably, the most important one of these two is retention. If you understand what makes your app sticky for your users, then you will be able to improve the retention rate.
Drongelen, Mike van, et al. Lean Mobile App Development, Packt Publishing, Limited, 2017. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/harrisburg-ebooks/detail.action?docID=5165112. Created from harrisburg-ebooks on 2020-12-01 07:19:37.
C o p yr
ig h t ©
2 0 1 7 . P
a ck
t P
u b lis
h in
g , L im
ite d . A
ll ri g h ts
r e se
rv e d .
Growing Traction and Improving Retention Chapter 15
[ 221 ]
You should always wonder: what's in it for them? And you should give your users some good reasons to come back to the app regularly. Social apps have the best retention rates. People come back because they want to be kept up to date on the regular stream of information. This is known as the fear of missing out (FoMo). It is a skill that Facebook has mastered completely. Unfortunately, unlike Facebook, most apps are not used on a daily basis.
Churn is a phenomenon that is more or less the opposite of retention. There will always be churn, but you can try to keep it as low as possible. Today, numbers show that if an app is not started once a week there is a chance that 60% of people will forget about it. You need to keep your app relevant. You have to regularly offer fresh content and new features. It is needless to say that you have to inform the user about these updates. You can send them push notifications for example. That is a very common approach to catch the attention of users and send them back to your app!
An onboarding experience with a low barrier, offering fresh and relevant content and features, personalization (social sign up strategies could help here), incentification, and sending push notifications are all features that can greatly contribute to better retention and engagement values.
Incentification is closely related to gamification. Both come with rewards if the user has come to a particular achievement in your app. While gamification is more about digital incentives, such as badges (as available at Foursquare and Stack Overflow, for example), incentification is about real-world, non-digital rewards, such as a free cup of coffee at the nearest coffee shop. If you want to learn more about the concept of incentification, you can check out http:// kiip. me.
There are many ways to improve retention, resulting in better traction. For now, we will just examine how to stay in touch with our users by enabling push notifications. You need to give people a reason to keep coming back and you often need to remind people of the existence of your app. If you do not want your app to be forgotten, abandoned, and eventually deleted, you should kindly remind them of the app.
There are many ways to improve retention, resulting in better traction. For now, we will just examine how to stay in touch with our users, by enabling push notifications. You need to give people a reason to keep coming back and you often need to remind people of the existence of your app. If you do not want your app to be forgotten, abandoned and eventually deleted, you should kindly remind them of the app.
Drongelen, Mike van, et al. Lean Mobile App Development, Packt Publishing, Limited, 2017. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/harrisburg-ebooks/detail.action?docID=5165112. Created from harrisburg-ebooks on 2020-12-01 07:19:37.
C o p yr
ig h t ©
2 0 1 7 . P
a ck
t P
u b lis
h in
g , L im
ite d . A
ll ri g h ts
r e se
rv e d .
Growing Traction and Improving Retention Chapter 15
[ 222 ]
Please do not spam your users. Do not send too many messages and try, through segmentation, to send relevant information only. If your user stays away for too long and if you have something interesting to share with them you can send them a friendly reminder. It is an excellent candidate for a concierge service if you want to learn what type of reminders work best. Find out what type of messages works best and see what customer segments will show the best conversions. Once you have learned that then you can do the automation later. If you already have a large user base you can also perform an A/B test to see what works best. There are many services available that can help you with both the segmenting of your customers and running split tests.
Also, think about the frequency of your reminders. Is one week of abstinence a good time to send out a reminder? Or is two weeks better? It is important to tell a story and to build an experience. Stating what is in it for them should come with a clear call to action, such as "Check out our new feature X" or "Look at what your friend Y has posted".
Push notifications can help to increase retention rates. Numbers show that, on average, users who have opted-in to receive push notifications results in 25% higher retention rates. That seems to make sense. By the way, push notifications for iOS apps are always opt-in. Only if users state that they do want to receive push notifications, they will receive them. Android has an opt-out mechanism. Users install an app and they will receive push notifications unless they choose to opt-out.
Notifications There are three ways of communicating with your app users using notification messages and badges:
Local notifications Push notifications In-app notifications
Local notifications Local notifications are like services, running on the user's device. The app does not need to be active to receive a local notification related to your app. They also do not need internet access or a server. Instead, they are scheduled for a particular date and time, like an alarm. They are initialized by your app.
Drongelen, Mike van, et al. Lean Mobile App Development, Packt Publishing, Limited, 2017. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/harrisburg-ebooks/detail.action?docID=5165112. Created from harrisburg-ebooks on 2020-12-01 07:19:37.
C o p yr
ig h t ©
2 0 1 7 . P
a ck
t P
u b lis
h in
g , L im
ite d . A
ll ri g h ts
r e se
rv e d .
Growing Traction and Improving Retention Chapter 15
[ 223 ]
What you can do is schedule a local notification to remind the user about the app but cancel it as soon as the user launches your app. It is a great instrument to remind your user about your app's existence:
You can use local notifications to increase your app's retention rate. You can schedule a notification when your app is closed or loses focus but cancel them when your app becomes active again. If you set the fire date to one or two weeks from now and users forget about your app, they will receive a friendly reminder. If, however, they use the app within this particular time frame, then the notification will be canceled and the user will not be bothered with any reminder notifications.
Push notifications Push notifications involve a server (and with that an internet connection) that initiates the action. Such notifications are a great instrument for promotional actions, and can inform the user about the availability of new content and new features in the app. Further, it depends on the nature of the app to decide what notifications will be relevant. For a dating app, it would be nice to be notified about a new app. In this case, displaying a badge on the icon of the app indicating the number of new matches and messages also would be very helpful. For a news app, it would be great to receive a notification each time a new and important message comes in. You can create user segments based on interest or based on their geographical location, for example, to notify your user only about local news events.
In-app notifications Finally, you can use in-app notifications to indicate that there are new events. You can display a badge at those places, where it is relevant. This could be a tab or a menu item. You can also use app notifications to stimulate particular behavior while your app is being used. Think, for example, of a reminder notification such as "Rate this app 5 stars!" Some methods can be quite clever, like a dialog that is only shown if the user has used the app five times (engagement) and the app has not crashed.
Drongelen, Mike van, et al. Lean Mobile App Development, Packt Publishing, Limited, 2017. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/harrisburg-ebooks/detail.action?docID=5165112. Created from harrisburg-ebooks on 2020-12-01 07:19:37.
C o p yr
ig h t ©
2 0 1 7 . P
a ck
t P
u b lis
h in
g , L im
ite d . A
ll ri g h ts
r e se
rv e d .
Growing Traction and Improving Retention Chapter 15
[ 224 ]
Only then will the dialog ask for a 5-star rating! It is important to provide convenience and lower the barrier to rate the app for your users that are enthusiastic about your app. For users who might be less happy with your app, you can keep the barrier as is. This will help you get better App/Play Store ratings.
There are components that do exactly this. One of them is iRate for iOS. With only a few lines of code, you can implement a 'Rate us' or 'Give us 5 stars' popup in your app. You can configure when and under what conditions it will be shown:
For each type of notification, it is important to not be annoying. Do not ask too much from the user too often. You should only notify a user if there is something relevant to mention. A push notification for no particular reason, just to let the user come back to the app may convert well once. However, if this happens too often, it will become annoying and your users might uninstall the app instead.
Services for push notifications To distribute your push notifications to your Android and iOS devices, you need to have a push notification server that will distribute messages to the correct devices. Although you can build this yourself, it is more convenient to use one of the ready-made solutions that are available for this purpose. The benefits of existing solutions, besides a big-time saver, will be their scalability, multi-platform support, and segmentation options, making it easier to determine which message goes to what user.
Some examples of such solutions are Urban Airship, Azure Push Notification Hub, Amazon Push, Hosted Parse Servers solutions, as found at back4app.com for example, and Firebase push notification services. They all have different pricing plans and they support different OSs.
Drongelen, Mike van, et al. Lean Mobile App Development, Packt Publishing, Limited, 2017. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/harrisburg-ebooks/detail.action?docID=5165112. Created from harrisburg-ebooks on 2020-12-01 07:19:37.
C o p yr
ig h t ©
2 0 1 7 . P
a ck
t P
u b lis
h in
g , L im
ite d . A
ll ri g h ts
r e se
rv e d .
Growing Traction and Improving Retention Chapter 15
[ 225 ]
As an example, here is a schematic view of Azure Push notification hubs. It can deliver push notifications to iOS and Android (And Windows Phone if you still really want to do so):
If you want to deliver push notifications to operating systems other than Android or iOS, or if you want to deliver push notifications outside the western world, it is good to carefully examine the different options. Let's say you want to deliver your app to the Chinese market as well. In that case, it is good to know that Amazon supports Baidu Push notifications, since this is not supported by all services. Amazon has a single hub for sending notifications to any device no matter if it is running on Amazon, iOS, Baidu, Android or Windows.
Push notifications for Android are delivered through the Google Cloud Messaging (GCM) protocol. Apple uses Apple Push Notification Service (APNS) for iOS. Configuring push notifications for iOS is a little bit more complicated as it requires some hassle with certificates. However, if you are an iOS developer using certificates and distribution profiles, then you will not be scared of it.
Drongelen, Mike van, et al. Lean Mobile App Development, Packt Publishing, Limited, 2017. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/harrisburg-ebooks/detail.action?docID=5165112. Created from harrisburg-ebooks on 2020-12-01 07:19:37.
C o p yr
ig h t ©
2 0 1 7 . P
a ck
t P
u b lis
h in
g , L im
ite d . A
ll ri g h ts
r e se
rv e d .
Growing Traction and Improving Retention Chapter 15
[ 226 ]
Back4App is a party that is offering Parse server hosting including support for push notifications (Android and iOS). You can easily target all users or specific users (segments):
As you can see, most services offer support for Android and iOS and a couple of other platforms. Scalability, supported platforms, pricing plans, and ease of integration are all things to consider when choosing a push notification service provider:
Amazon Apple (APNS)
Baidu Google (GCM) Microsoft
Amazon Supported Supported Supported Supported Supported
Azure Supported Supported Not sure Supported Supported
Firebase Supported Supported ?
Urban Airship Supported Supported Supported Supported
Parse Server Supported Supported
Drongelen, Mike van, et al. Lean Mobile App Development, Packt Publishing, Limited, 2017. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/harrisburg-ebooks/detail.action?docID=5165112. Created from harrisburg-ebooks on 2020-12-01 07:19:37.
C o p yr
ig h t ©
2 0 1 7 . P
a ck
t P
u b lis
h in
g , L im
ite d . A
ll ri g h ts
r e se
rv e d .
Growing Traction and Improving Retention Chapter 15
[ 227 ]
Implementation The approach for both platforms is more or less the same. If the user launches the app, the device and app will be registered for receiving push notifications. It will result in a token (or an optional registration ID for Android) that you can use later to send a notification to this particular device and for this particular app. The main difference between Android and iOS is that iOS uses an opt-in strategy for receiving notifications, while Android uses an opt-out strategy.
An iPhone user will see a question pop up which asks if he wants to allow the app to receive push notifications (opt-in). This is something the OS does for us when we register as shown as follows:
For Android, we will just register the device and the app and we will receive push notifications, which the user won't notice until he receives his first notification. On Android, you can turn receiving push notifications off (opt out) using the Settings app.
So, here is an Android Java example of such registrations in your App class. The GCM_PROJECT_NUMBER refers to the project number in the Google developer console, but we will come to that later:
private GoogleCloudMessaging gcm; ... String regid = gcm.register(FlavorConstants.PushConfiguration.GoogleConfiguration. GCM_PROJECT_NUMBER); Log.i(getClass().toString(), "Obtained RegId from GCM : " + regid);
Additionally, here is how it is done for iOS (Swift 3.x, iOS 10) in the AppDelegate class. For iOS, you also need to configure a couple of things in the developer's portal, which we will see later:
func registerForPushNotifications(){ print ("PN - register for PN") let center = UNUserNotificationCenter.current() center.delegate = self center.requestAuthorization(options:[.badge, .alert, .sound]) { (granted, error) in if error == nil { print ("PN - No error") } else{ print ("PN - Error ") } if (!granted){ print ("PN - Not granted")
Drongelen, Mike van, et al. Lean Mobile App Development, Packt Publishing, Limited, 2017. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/harrisburg-ebooks/detail.action?docID=5165112. Created from harrisburg-ebooks on 2020-12-01 07:19:37.
C o p yr
ig h t ©
2 0 1 7 . P
a ck
t P
u b lis
h in
g , L im
ite d . A
ll ri g h ts
r e se
rv e d .
Growing Traction and Improving Retention Chapter 15
[ 228 ]
} else{ print ("PN - granted") } guard granted else { return } self.getNotificationSettings() } } func getNotificationSettings() { UNUserNotificationCenter.current().getNotificationSettings { (settings) in print("Notification settings: \(settings)") guard settings.authorizationStatus == .authorized else { return } UIApplication.shared.registerForRemoteNotifications() } }
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { let installation = PFInstallation.current() installation?.setDeviceTokenFrom(deviceToken) installation?.saveInBackground() PFPush.subscribeToChannel(inBackground: "global") { (result, error) in print("PN - subscribed to global") } }
Setup To set up GCM for your Android app, you have to go to your Google Developer Console, which you can find at https:/ / console. developers. google. com/ .
There you can configure your app and obtain a server key.
Drongelen, Mike van, et al. Lean Mobile App Development, Packt Publishing, Limited, 2017. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/harrisburg-ebooks/detail.action?docID=5165112. Created from harrisburg-ebooks on 2020-12-01 07:19:37.
C o p yr
ig h t ©
2 0 1 7 . P
a ck
t P
u b lis
h in
g , L im
ite d . A
ll ri g h ts
r e se
rv e d .
Growing Traction and Improving Retention Chapter 15
[ 229 ]
To set up Apple push notifications (APNS), you need to go the Apple Developer's portal and find your app at the identifiers/app ID's section (assuming that you have already created an app id for your app):
Click on the Edit button and scroll down to the Push Notifications section. Click on the Download button to download the certificate or click on the Create Certificate button depending on your needs.
Follow the instructions. Use the keychain app to create a CSR file (certificate signing request). Doing this from the building machine is preferable.
Drongelen, Mike van, et al. Lean Mobile App Development, Packt Publishing, Limited, 2017. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/harrisburg-ebooks/detail.action?docID=5165112. Created from harrisburg-ebooks on 2020-12-01 07:19:37.
C o p yr
ig h t ©
2 0 1 7 . P
a ck
t P
u b lis
h in
g , L im
ite d . A
ll ri g h ts
r e se
rv e d .
Growing Traction and Improving Retention Chapter 15
[ 230 ]
Upload the request file (CSR) to the Apple Developer's portal:
Download the certificate (that will contain both the private and public part) and double- click to install. In the keychain app, find the APNS certificate and choose Export from the Context menu.
Provide a password for the file and save it. You now have a file with a P12 extension that you can later upload to your notification service, for example, to Azure Push Notification hubs.
The following example shows the section in Notification hubs, where you can upload this certificate file in sandbox mode (development only). This approach is more or less the same for other services. They all require you to upload this file to make the magic happen:
Drongelen, Mike van, et al. Lean Mobile App Development, Packt Publishing, Limited, 2017. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/harrisburg-ebooks/detail.action?docID=5165112. Created from harrisburg-ebooks on 2020-12-01 07:19:37.
C o p yr
ig h t ©
2 0 1 7 . P
a ck
t P
u b lis
h in
g , L im
ite d . A
ll ri g h ts
r e se
rv e d .
Growing Traction and Improving Retention Chapter 15
[ 231 ]
The following is an example of all the push services you can configure here:
After deciding which notification service to use, find some good references (books or tutorials on the subject) as, in particular, iOS push notification configuration can be a bit tricky.
Drongelen, Mike van, et al. Lean Mobile App Development, Packt Publishing, Limited, 2017. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/harrisburg-ebooks/detail.action?docID=5165112. Created from harrisburg-ebooks on 2020-12-01 07:19:37.
C o p yr
ig h t ©
2 0 1 7 . P
a ck
t P
u b lis
h in
g , L im
ite d . A
ll ri g h ts
r e se
rv e d .
Growing Traction and Improving Retention Chapter 15
[ 232 ]
Handling an incoming notification If a notification comes in, it will be shown in the Messenger section, something that the OS will provide for us. In addition, we can define what to do with it. In Android, we can implement a PushHandler class that consumes the notification and defines specific actions for it using the NotificationCompat builder. Here is an Android Java example:
public class PushHandler extends NotificationsHandler {
Context ctx;
@Override public void onReceive(Context context, Bundle bundle) { ctx = context; String nhMessage = bundle.getString("message"); Parcelable parselableObject = bundle.getParcelable("parcel"); consumeNotification(nhMessage,parselableObject); }
private void consumeNotification(String msg, Parcelable parselableObject) {
Log.i(this.getClass().toString(), "Consume notification"); Log.i(this.getClass().toString(), "Notification msg = "+msg);
if (parselableObject != null) { Log.i(this.getClass().toString(), "Consume has parcel"); }
displayNotificationMessage(ctx, "Message", msg,msg); }
public static void displayNotificationMessage(Context context, String title, String contentText, String tickerText){ displayNotificationMessage(context,title,contentText,tickerText,null); }
public static void displayNotificationMessage(Context context, String title, String contentText, String tickerText, Parcelable parcelableObject){
... NotificationCompat.Builder builder = new NotificationCompat.Builder(context); Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Drongelen, Mike van, et al. Lean Mobile App Development, Packt Publishing, Limited, 2017. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/harrisburg-ebooks/detail.action?docID=5165112. Created from harrisburg-ebooks on 2020-12-01 07:19:37.
C o p yr
ig h t ©
2 0 1 7 . P
a ck
t P
u b lis
h in
g , L im
ite d . A
ll ri g h ts
r e se
rv e d .
Growing Traction and Improving Retention Chapter 15
[ 233 ]
Bundle extras = new Bundle(); extras.putParcelable("parcel", parcelableObject);
Notification notification = builder.setContentTitle(title) .setContentText(contentText) .setTicker(tickerText) .setSmallIcon(R.mipmap.appicon) .setContentIntent(pendingIntent) .setPriority(Notification.PRIORITY_HIGH) .setSound(soundUri) .setVibrate(new long[]{0, 500}) .setExtras(extras) .build();
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(0, notification); }
For iOS, you can do the same thing. This is the event handling in the AppDelegate class, and it is a Swift 4/3.x, iOS 11 example (for previous versions of iOS, it works in a different way), and it uses the Parse Server to get the push notifications delivered.
Here, we can determine as well what should happen when a push notification arrives (to some extent). The completion handler determines if a notification or badge is shown and if a sound will be played:
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { print("Failed to register: \(error)") } func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { print ("PN - willPresent") let userInfo = notification.request.content.userInfo as NSDictionary let body = notification.request.content.body for (key, value) in userInfo { print("userInfo: \(key) -> value = \(value)") } if ... { print ("PN - completion handler silent") completionHandler([]) } else{ print ("PN - completion handler alert badge sound")
Drongelen, Mike van, et al. Lean Mobile App Development, Packt Publishing, Limited, 2017. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/harrisburg-ebooks/detail.action?docID=5165112. Created from harrisburg-ebooks on 2020-12-01 07:19:37.
C o p yr
ig h t ©
2 0 1 7 . P
a ck
t P
u b lis
h in
g , L im
ite d . A
ll ri g h ts
r e se
rv e d .
Growing Traction and Improving Retention Chapter 15
[ 234 ]
completionHandler([.alert,.badge, .sound]) } } ... } func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { print ("PN - Did receive") ... completionHandler() }
Sending a notification To send a notification, you can use the web interface of the service or you can use the features that the service provides if you want to send a message programmatically.
The following is a cloud code example for the Parse Server (Back4App). It sends a message to all devices that are listening to a particular channel. You can send a push notification to all users or you can set up channels for customer segmentation. You can set the number of the badge on the icon (iOS only), the title, and the message:
Parse.Push.send({ channels: "channel or channels", data: { title: "title", sound: 'default', badge: 2, alert: "message", extraParam: "something" } }, { success: function () { response.success("ok"); }, error: function (error) { response.success("nok: " + error); }, useMasterKey: true }); // push send
No matter which service you are using, the basic payload is always the same. Also, note that you can send custom parameters with it:
data: { title: "title", sound: 'default', badge: 2, alert: "message", extraParam: "something" }
So far, for a high-level perspective on push notifications, you now have an idea what it takes to implement it. To continue on this subject, examine the tutorials that Google and Apple provide about it.
Drongelen, Mike van, et al. Lean Mobile App Development, Packt Publishing, Limited, 2017. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/harrisburg-ebooks/detail.action?docID=5165112. Created from harrisburg-ebooks on 2020-12-01 07:19:37.
C o p yr
ig h t ©
2 0 1 7 . P
a ck
t P
u b lis
h in
g , L im
ite d . A
ll ri g h ts
r e se
rv e d .
Growing Traction and Improving Retention Chapter 15
[ 235 ]
Summary In this chapter, you learned what the definition of traction is and why it is important. We have seen that engagement and retention are important elements too. We have seen that there are different types of notifications and what the benefits are of each type. You can remind your user about specific events in your app. This will increase the retention rate. Notifications can also help you to improve the awareness for your app, for example, by asking for a user rating for your app. Finally, we have seen what notification services exist to deliver push notifications and what it takes to actually implement a push notification mechanism for your Android and iOS apps.
In the next chapter, we will investigate scalability. In the beginning, you often do things that do not scale, but once you have established sufficient amount of traction, it is time to think about a scalability strategy. This is particularly important when your app uses a backend.
Drongelen, Mike van, et al. Lean Mobile App Development, Packt Publishing, Limited, 2017. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/harrisburg-ebooks/detail.action?docID=5165112. Created from harrisburg-ebooks on 2020-12-01 07:19:37.
C o p yr
ig h t ©
2 0 1 7 . P
a ck
t P
u b lis
h in
g , L im
ite d . A
ll ri g h ts
r e se
rv e d .