Tuesday, May 19, 2015

Unity Engine and Push Notifications for iOS

Just recently I was looking for a way to use iOS push notifications in the application based on Unity Engine. To make it clear, this notifications appears every time any iOS app has something to tell the user in 3 different ways:
  • An onscreen alert or banner
  • A badge on the app’s icon
  • A sound that accompanies an alert, banner, or badge

For further reading you can use this and this. While googling for push notification integration with Unity, I've found lot's of plugins that promised me to perform such an integration. To my suprise, Unity itself provided some classes to wrap low level coding for creating push notifications. At least unity 4.6 has them. 

Main class for such a task is NotificationServices. To start working with notifications you should register with RegisterForNotifications method. After that you can use deviceToken for remote notifications or start using local notifications. If you still don't know which one to use, try to read this. To configure application for remote push notification you can use this guide, just make sure you will scip section for creating iOS app and create Unity app instead. If you are testing remote notifications you can use my simple script ( get it here ), just attach it to anything on the scene and build it for iOS. Sending local notifications even easier and do not require any additional configuration. Last but not the least, to test that your app really aquire remote notifications you need another app, that will send this notification to Apple Push Notification Service. How to create such a provider you can read here, in the section "Creating Push Notification Provider". Don't forget to store deviceToken from xcode console when running test unity app and use that token in PushMeBaby application.

In the end, you'll be able to send notifications from notification provider and get them in your Unity application. 

Friday, February 13, 2015

Deep zoom in Unity

I faced a problem of showing a high-resolution images. The problem was to provide the ability to interactively view big pictures and zoom deeply. Well first idea of just scaling a picture is not worth of mentioning, because the quality of the zoomed image is really bad. Next thing I saw was an microsoft silverlight technology called Deep Zoom. You can read more about it by following the link. Main idea is to make several copies of original image with different resolution, divide them into tiles and show not whole image with resolution 20000 by 20000 but only visible tiles. They call it an image pyramid. Worth mentioning that google maps uses basically the same idea. So I've tried to implement that idea to show really big images with deep zoom in Unity project. To watch this demo you need to enable Unity plugin first. Them you can interact with map and use zooming.
Clone google maps in Unity