push notification with unity in ios using app42 backend
DESCRIPTION
Integrating App42 Push Notification service with Unity3D iOS App. With Unity you can create rich, interactive entertainment or multimedia experience. This presentation will help you learn how to use Unity Push Notification feature with App42 Backend as a Service APIs. Check out our website http://www.shephertz.comTRANSCRIPT
![Page 1: Push Notification with Unity in iOS using App42 Backend](https://reader034.vdocuments.us/reader034/viewer/2022052304/55980da21a28ab352c8b4855/html5/thumbnails/1.jpg)
Push Notification Service
![Page 2: Push Notification with Unity in iOS using App42 Backend](https://reader034.vdocuments.us/reader034/viewer/2022052304/55980da21a28ab352c8b4855/html5/thumbnails/2.jpg)
Increase User
Engagement
Calendar Events
Message
Pop-Up
Latest
Updates
Push Notifications
![Page 3: Push Notification with Unity in iOS using App42 Backend](https://reader034.vdocuments.us/reader034/viewer/2022052304/55980da21a28ab352c8b4855/html5/thumbnails/3.jpg)
Benefits of Push Notification
Increases user-engagement
e.g. In a turn-based game like Tic-Tac-Toe, it can notify a user of his turn (suppose
he gets a phone call in between and forgets that he was playing!!)
Allows to send messages to users even when the app is not running; thus helps in
reminding them of your App
Helps to build a fan community around your game by pushing to a targeted
audience – like your regular gamers
Allows an App to notify its users of new events without needing to actually open it,
i.e. by a sound or a screen pop up
![Page 4: Push Notification with Unity in iOS using App42 Backend](https://reader034.vdocuments.us/reader034/viewer/2022052304/55980da21a28ab352c8b4855/html5/thumbnails/4.jpg)
App42 Push Notification supports
iOS
Android
Windows
Unity
Flash
HTML 5
Cocos2dx
Corona.. And more
![Page 5: Push Notification with Unity in iOS using App42 Backend](https://reader034.vdocuments.us/reader034/viewer/2022052304/55980da21a28ab352c8b4855/html5/thumbnails/5.jpg)
Our Push Notification API can be used to send cross-
platform push messages to devices running on iOS,
Android and Windows Phone with a single API call
• Send Image/Text/URLs text-based Push Notifications
• Send messages in Channel Subscription Mode
• Send Scheduled Push as per Time-Zone
No infrastructure & scalability worries
Push Analytics
• Analyze your Push Campaign with App42 Analytics
• Evaluate the number of Push messages sent, delivered
and opened
Why App42 Push Notification?
![Page 6: Push Notification with Unity in iOS using App42 Backend](https://reader034.vdocuments.us/reader034/viewer/2022052304/55980da21a28ab352c8b4855/html5/thumbnails/6.jpg)
Push for Marketing Automation
Segment your Users and send targeted Push Notifications
• Segmentation based on User Profile, Interests, Channel Subscription, etc.
• Geo-Location based Push Notifications
Track User Activity, set custom events and trigger Push Notifications based on
Users’ Current/Real-time or Previous Sessions’ Activity
• Set custom events such as App Open, Click on a Link, App Session Close, In-App
Purchase, Add to Cart, etc.
• Trigger real-time Push Notifications based on Event occurrences
![Page 7: Push Notification with Unity in iOS using App42 Backend](https://reader034.vdocuments.us/reader034/viewer/2022052304/55980da21a28ab352c8b4855/html5/thumbnails/7.jpg)
Creating a channel & scheduling
Push messages through AppHQ
![Page 8: Push Notification with Unity in iOS using App42 Backend](https://reader034.vdocuments.us/reader034/viewer/2022052304/55980da21a28ab352c8b4855/html5/thumbnails/8.jpg)
A very useful feature that can track:
These analytics can be viewed from our AppHQ console.
Why Push Analytics?
When you use our Push Notification Service, each Push goes from the App42 server to
GCM/APNS/MPNS and then to the user device.
Thus, Analytics gives you a better insight of your Push Notification campaign.
Push Analytics
• Delivery of Push Notification is not guaranteed even from the service provider
• Once delivered, there might be a chance that user just clears it without opening the message
How many Push Notifications were sent from your side
How many were delivered, and
How many users opened the message
100%
74%
31%
Push Notification Campaign
Sent
Delivered
Opened
![Page 9: Push Notification with Unity in iOS using App42 Backend](https://reader034.vdocuments.us/reader034/viewer/2022052304/55980da21a28ab352c8b4855/html5/thumbnails/9.jpg)
Integrate Push Notification
with Unity3d on iOS
![Page 10: Push Notification with Unity in iOS using App42 Backend](https://reader034.vdocuments.us/reader034/viewer/2022052304/55980da21a28ab352c8b4855/html5/thumbnails/10.jpg)
Steps to Integrate Push Notification
with Unity3d on iOS
Download our Sample App Source Code from our GitHub Repo.
To configure Push Notifications for iOS Apps/games; the prerequisites are:
• Create a new App ID and provisioning profile for each App that uses push as well as an SSL certificate
for the server. For this, you should have an iOS Developer Program Membership on iOS Dev Center
• Create .p12 file from the SSL certificate, which was downloaded from the iOS Dev Center
• You require a server!
Note: If you are new to Push Notifications for iOS or App42 , you can go through
our previous blog (Configure & Send Push Notification on iOS Device)
![Page 11: Push Notification with Unity in iOS using App42 Backend](https://reader034.vdocuments.us/reader034/viewer/2022052304/55980da21a28ab352c8b4855/html5/thumbnails/11.jpg)
How the sample code implements the Push Notifications by examining the key code snippets?
• Open the downloaded folder, go to the assets folder and double click PushSample.unity file to
open the sample
• To implement ‘Push’, drag and drop our “App42PushHandlerInternal.h/.m” classes to
“Assets/Plugins/iOS” folder and “PushScript.cs” C# script to “Assets” folder.
• Assign PushScript.cs to a game object; in demo it was assigned to the main camera. So, let’s
browse through the PushScript.cs code.
• To receive push notifications, iOS needs to be notified that your App wants to receive push
notifications, and “App42PushHandlerInternal.m” class does it by default .
• In PushScript, all the required call backs are defined and to get the call backs, set a listener game
object as:
Contd..
1 // Use this for initialization
2 void Start ()
3 {
4 setListenerGameObject(this.gameObject.name);
5 }
![Page 12: Push Notification with Unity in iOS using App42 Backend](https://reader034.vdocuments.us/reader034/viewer/2022052304/55980da21a28ab352c8b4855/html5/thumbnails/12.jpg)
• As “App42PushHandlerInternal.m” sends a request to register this device for push
notification service; the device token is received from Apple Push Service on the
successful response.
• It is available via “onDidRegisterForRemoteNotificationsWithDeviceToken” call back of
PushScript.cs.
Contd..
1 //Sent when the application successfully registered with Apple Push Notification Service (APNS).
2 void onDidRegisterForRemoteNotificationsWithDeviceToken(string deviceToken)
3 {4 if (deviceToken != null &&deviceToken.Length!=0)5 {
6 registerDeviceTokenToApp42PushNotificationService(deviceToken,"User Name");
7 }8 }
![Page 13: Push Notification with Unity in iOS using App42 Backend](https://reader034.vdocuments.us/reader034/viewer/2022052304/55980da21a28ab352c8b4855/html5/thumbnails/13.jpg)
• Register this device to App42 Push Notification Service to send/receive push
notifications.
• To do this, just call “registerDeviceTokenToApp42PushNotificationService” method of
PushScript.cs from the above call back
Contd..
1 //Registers a user with the given device token to APP42 push notification service
2 void registerDeviceTokenToApp42PushNotificationService(string devToken,string userName)
3 {
4 ServiceAPI serviceAPI = new ServiceAPI(api_key,secret_key);
5 PushNotificationService pushService = serviceAPI.BuildPushNotificationService();
6 pushService.StoreDeviceToken(userName,devToken,"iOS");
7 }
![Page 14: Push Notification with Unity in iOS using App42 Backend](https://reader034.vdocuments.us/reader034/viewer/2022052304/55980da21a28ab352c8b4855/html5/thumbnails/14.jpg)
• The SendPushToUser method of this script can be written/called to send a request to
App42 server to send a Push Notification to a specific user
Contd..
1 //Sends push to a given user
2 void SendPushToUser(string userName,string message)
3 {
4 ServiceAPI serviceAPI = new ServiceAPI(api_key,secret_key);
5 PushNotificationService pushService = serviceAPI.BuildPushNotificationService();
6 pushService.SendPushMessageToUser(userName,message);
7 }
![Page 15: Push Notification with Unity in iOS using App42 Backend](https://reader034.vdocuments.us/reader034/viewer/2022052304/55980da21a28ab352c8b4855/html5/thumbnails/15.jpg)
• The “onPushNotificationsReceived” call back of the PushScript will be called when you
receive a push notification
Contd..
1 //Sent when the application Receives a push notification
2 void onPushNotificationsReceived(string pushMessageString)
3 {
4 Console.WriteLine("onPushNotificationsReceived");
5 //dump you code here to handle the pushMessageString
6 Debug.Log(pushMessageString);
7 }
![Page 16: Push Notification with Unity in iOS using App42 Backend](https://reader034.vdocuments.us/reader034/viewer/2022052304/55980da21a28ab352c8b4855/html5/thumbnails/16.jpg)
Now,
• Your App is successfully set up to receive/send push notifications through our App42
Server using App42 Push Notification Service
• If you have any questions or need further assistance to integrate Push Notification in
your App, do write back at [email protected]
Contd..
![Page 17: Push Notification with Unity in iOS using App42 Backend](https://reader034.vdocuments.us/reader034/viewer/2022052304/55980da21a28ab352c8b4855/html5/thumbnails/17.jpg)
Sending a message
through AppHQ console
![Page 18: Push Notification with Unity in iOS using App42 Backend](https://reader034.vdocuments.us/reader034/viewer/2022052304/55980da21a28ab352c8b4855/html5/thumbnails/18.jpg)
IT IS THAT SIMPLE!!!
![Page 19: Push Notification with Unity in iOS using App42 Backend](https://reader034.vdocuments.us/reader034/viewer/2022052304/55980da21a28ab352c8b4855/html5/thumbnails/19.jpg)
Some useful links
Getting Started:
Quick Start Guide
Sign-up for Free
Game Development Center
Concepts:
Backend as a Service
Massive Multiplayer Gaming Engine
App Analytics
Products:
App42 Cloud APIs - BaaS
AppWarp – Multiplayer Gaming Engine
AppHQ – Management Console
Downloads:
App42 Cloud SDKs
App 42 Modules
Blogs:
Why BaaS?
Push Notification for iOS
Push Notification for Android
Real-time Multiplayer Games using Unity3D
Integrating Facebook in your Android App
Making a Turn-based Game
Using Query Interface
When to use NoSQL?
Add ‘Social’ to your Game
![Page 20: Push Notification with Unity in iOS using App42 Backend](https://reader034.vdocuments.us/reader034/viewer/2022052304/55980da21a28ab352c8b4855/html5/thumbnails/20.jpg)
Links for Reference :http://www.shephertz.com
http://api.shephertz.com
http://appwarp.shephertz.com
http://app42paas.shephertz.com
Follow us on:
Contact: [email protected]
Skype: ShepHertz