Push Notifications

iOS Android

Another way of using HOKO smart links inside your app is to send them via your push notifications. In this guide, we will show you how to do it with Parse and Mixpanel.

With Parse

To setup your push notifications with Parse, check out this great guide, created by the folks at Parse, to get started with their push service.

After setting up your application, your push notification should contain the following data:

{
  "alert": "Hi! This is my super awesome notification title.",
  "uri": "https://yourapp.hoko.link/superawesomelink"
}

With Mixpanel

Check out this great guide to setup your app in order to start receiving Push Notifications and this guide to start sending them from your Dashboard.

After setting up your application, your push notification should contain the following data:

{
  "aps": {
    "alert": "Hi! This is my super awesome notification title.",
    "uri": "https://yourapp.hoko.link/superawesomelink"
  }
}

With your own custom server

If you have your own server and want to use it to manually send push notifications to your users, we strongly recommend you to take a look at these great guides, created by the folks at Ray Wenderlich, to help you set up your server and application: Part 1 and Part 2.

After setting up the app, your push notification data should look like the following:

{
  "aps": {
    "alert": "Hi! This is my super awesome notification title."
  },
  "uri": "https://yourapp.hoko.link/superawesomelink"
}

Finally, for both services

To decode and process your notifications on the user’s device, make sure you have the application:didReceiveRemoteNotification: delegate method implemented and the rest super easy! The following code shows you how:

// AppDelegate.m
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
  // check if the push notification has the key "uri" (the smart link)
  if (userInfo[@"uri"]) {
    // if so, call HOKO's openSmartlink: and we'll take care of it for you
    // by sending the request to the appropriate route for that smartlink
    [[Hoko deeplinking] openSmartlink:userInfo[@"uri"]];
  } else {
    // otherwise, process the notification with your own code
    // in this case, processUserActivity: would be one of your methods
    [self processPushNotification:userInfo];
  }
}
// AppDelegate.swift
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
  // check if the push notification has the key "uri" (the smart link)
  if let smartlink = userInfo["uri"] as? String {
    // if so, call HOKO's openSmartlink() and we'll take care of it for you
    // by sending the request to the appropriate route for that smartlink
    Hoko.deeplinking().openSmartlink(smartlink)
  } else {
    // otherwise, process the notification with your own code
    // in this case, processUserActivity() would be one of your methods
    processPushNotification(userInfo)
  }
}

After this, you’re finally ready to become a Push Notifications Sensei.