Reputation: 374
I'm trying to use PushWoosh SDK (http://docs.pushwoosh.com/docs/native-ios-sdk) in my Nativescript (angular with typescript) project. for this reason i did the following:
Results of running on a device:
It seems like everything is fine, but the registration callbacks are not called, and if i try to call "getPushToken" in "applicationDidBecomeActive" it is null, and as i said - no "push enabled" devices in Pushwoosh portal.
AppDelegate.ios.ts:
import * as application from "application";
import "@zapsod/ns-pushwoosh" // My PW Plugin
import { ios } from "application";
import {platformCommon} from "./platform-common"
declare var PushNotificationManager;
declare var PushNotificationDelegate;
declare interface PushNotificationDelegate{
onPushAccepted(pushManager, withNotification, onStart);
didRegisterForRemoteNotificationsWithDeviceToken(deviceToken);
didFailToRegisterForRemoteNotificationsWithError(error);
didReceiveRemoteNotification(userInfo, completionHandler);
}
var pushManager =PushNotificationManager.pushManager();
//var PushNotificationManager = <any>pw.PushNotificationManager;
export class MyDelegate extends UIResponder implements
UIApplicationDelegate, PushNotificationDelegate{
public static ObjCProtocols = [UIApplicationDelegate,
PushNotificationDelegate];
applicationDidFinishLaunchingWithOptions(application: UIApplication,
launchOptions): boolean {
console.profile();
console.log("applicationWillFinishLaunchingWithOptions: ", this)
pushManager.delegate = this;
UNUserNotificationCenter.currentNotificationCenter().delegate =
pushManager.notificationCenterDelegate;
pushManager.sendAppOpen();
console.log(application.currentUserNotificationSettings);
pushManager.registerForPushNotifications();
return true;
}
applicationDidBecomeActive(application: UIApplication): void {
console.log("applicationDidBecomeActive: " + application)
console.log("is registered",
application.registeredForRemoteNotifications)
}
onPushAccepted(pushManager, withNotification, onStart){
console.log("pushaccepted", withNotification)
}
didRegisterForRemoteNotificationsWithDeviceToken(deviceToken) {
console.info("registered for pushed token ", platformCommon)
platformCommon.pushToken = deviceToken;
pushManager.handlePushRegistration(deviceToken);
}
didFailToRegisterForRemoteNotificationsWithError(error){
console.error("failed to register push ", error)
pushManager.handlePushRegistrationFailure(error)
}
didReceiveRemoteNotification(userInfo, completionHandler){
pushManager.handlePushReceived(userInfo);
completionHandler(UIBackgroundFetchResult.NoData);
}
}
application.ios.delegate = MyDelegate;
Upvotes: 1
Views: 274