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:
- Extended UIApplicationDelegate (code below)
- Added nativescript-entitlments plugin. with aps-environment (tried both development and production values).
- Added the required props to in info.plist (including even Pushwoosh_APPID_dev), and added remote-notification to UIBackgroundModes
- Created and uploaded my certificates to two different pushwoosh apps (one for dev, one for prod). and have my AppId allow push notification
- Created and installed a pushwoosh plugin. which includes a podfile. (I even tried adding 'use_frameworks!' to that podfile.
- I tried running through local "tns run ios" and also through TestFlight
Results of running on a device:
- The delegate runs, the SDK methods are being called Without errors. The app asks me to allow push notifications when i open it.
- In Pushwoosh portal I can see change in my IOS device count, but none of the devices are "Push enabled" (what does it mean?)
- In Pushwoosh statistics I can see "app open" events from IOS.
- application.currentUserNotificationSettings seems OK
- application.registeredForRemoteNotifications returns True.
- PushWoosh static method 'PushNotificationManager.getRemoteNotificationStatus' returns everything with value 1 (enabled, sound, etc).
- In debug mode i can see that Pushwoosh reads AppCode (and name and hwid) properties well.
- when I run it on a device i see no Pushwoosh logging in the console. even though i used Pushwoosh_LOG_LEVEL VERBOSE in info.plist. but if i run it on the emulator i can see Pushwoosh log events and outgoing requests. WHY? Logs are important, what is the different between the emulator and a device? I tried many things to solve this. What can be done?
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;