Closed gunawan0706 closed 4 years ago
You can use
var evt = onesignal.getPermissionSubscriptionState();
evt.subscriptionStatus.userId
You can use
var evt = onesignal.getPermissionSubscriptionState();
evt.subscriptionStatus.userId
Thanks Jordan, I tried it using version 2.2.0 and
var onesignal = require('com.williamrijksen.onesignal');
onesignal.setInFocusDisplayType('none');
onesignal.promptForPushNotificationsWithUserResponse(function(obj) {
var evt = onesignal.getPermissionSubscriptionState();
console.log(evt);
});
gives me undefined.
Fixed! On the new released version 2.1.1 I've implemented this onesignal.getPermissionSubscriptionState
method for iOS like @jordanbisato says. It should work just fine now!
I have the same issue. I'm using the latest version 2.2.2 with TiSDK 8.3.x,
This is the snippet I'm using:
var onesignal = Alloy.Globals.oneSignal = require('com.williamrijksen.onesignal');
onesignal.setInFocusDisplayType('none');
onesignal.setLogLevel({
logLevel: onesignal.LOG_LEVEL_DEBUG,
visualLevel: onesignal.LOG_LEVEL_DEBUG
});
onesignal.promptForPushNotificationsWithUserResponse(function(resp) {
//alert(JSON.stringify(resp));
var subscribed = onesignal.retrieveSubscribed();
console.log("subscribed", subscribed);
var playerId = onesignal.retrievePlayerId();
console.log("playerId", playerId);
var token = onesignal.retrieveToken();
console.log("token", token);
var substate = onesignal.getPermissionSubscriptionState();
console.log("substate", substate);
});
These are the logs from my device:
[DEBUG] com.williamrijksen.onesignal configure [com.xxx] Getting notification settings (async) [com.xxx] Got notification settings [ hasResult: 1 hasCompletionHandler: 1 ] [com.xxx] Requesting authorization with options 7 [DEBUG] com.williamrijksen.onesignal FIRE cold boot NotificationOpened [com.xxx] Requested authorization [ didGrant: 1 hasError: 0 hasCompletionHandler: 1 ] [DEBUG] com.williamrijksen.onesignal User accepted notifications: 1 [INFO] subscribed \^[[33mfalse\^[[39m [INFO] playerId \^[[90mundefined\^[[39m [INFO] token \^[[90mundefined\^[[39m [INFO] substate { subscriptionStatus: { userSubscriptionSetting: \^[[33mtrue\^[[39m, subscribed: \^[[33mfalse\^[[39m, userId: \^[[1mnull\^[[22m, pushToken: \^[[1mnull\^[[22m }, permissionStatus: { status: \^[[33m2\^[[39m, provisional: \^[[33mfalse\^[[39m, hasPrompted: \^[[33mtrue\^[[39m }, emailSubscriptionStatus: { emailAddress: \^[[1mnull\^[[22m, emailUserId: \^[[1mnull\^[[22m } } INFO: Device Registered with Apple: 773a44cdb0344203131ce5942c6d97f2b2b812dd574c5c9390ccbc2ad76b9096
I followed every step from the list, but the device doesn't subscribe.
I have other appcelerator projects that are working even with older versions of the onesignal sdk.
can you test by calling these functions out of the onesignal.promptForPushNotificationsWithUserResponse
callback function scope?
same thing..
I'm using Ti.API.info("SubscriptionState: " + JSON.stringify(SubscriptionState))
Any update for replacing idsAvailable to get Player ID in iOS?