moved registerDevice out of app