Skip to content

Commit

Permalink
Merge pull request #1537 from OneSignal/user_model_ga
Browse files Browse the repository at this point in the history
[User Model] GA Upates
  • Loading branch information
nan-li authored Aug 18, 2023
2 parents 2314ab6 + 39c6665 commit 3472b8b
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 41 deletions.
46 changes: 24 additions & 22 deletions MIGRATION_GUIDE.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies {

// api is used instead of implementation so the parent :app project can access any of the OneSignal Java
// classes if needed. Such as com.onesignal.NotificationExtenderService
api 'com.onesignal:OneSignal:5.0.0-beta4'
api 'com.onesignal:OneSignal:5.0.0'

testImplementation 'junit:junit:4.12'
}
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ public void removeGroupedNotifications(String id) {
}


// OneSignal.User.PushSubscription namespace methods
// OneSignal.User.pushSubscription namespace methods
@ReactMethod
public void getPushSubscriptionId(Promise promise) {
IPushSubscription pushSubscription = OneSignal.getUser().getPushSubscription();
Expand Down
10 changes: 5 additions & 5 deletions examples/RNOneSignalTS/src/OSButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ class OSButtons extends React.Component<Props> {
'Get Push Subscription Id',
async () => {
const id =
await OneSignal.User.PushSubscription.getPushSubscriptionId();
await OneSignal.User.pushSubscription.getPushSubscriptionId();
loggingFunction('Push Subscription Id: ', id);
},
);
Expand All @@ -364,24 +364,24 @@ class OSButtons extends React.Component<Props> {
'Get Push Subscription Token',
async () => {
const token =
await OneSignal.User.PushSubscription.getPushSubscriptionToken();
await OneSignal.User.pushSubscription.getPushSubscriptionToken();
loggingFunction('Push Subscription Token: ', token);
},
);

const getOptedInButton = renderButtonView('Is Opted In', async () => {
const optedIn = await OneSignal.User.PushSubscription.getOptedIn();
const optedIn = await OneSignal.User.pushSubscription.getOptedIn();
loggingFunction('Subscribed for the push notifications: ', optedIn);
});

const optInButton = renderButtonView('Opt In', () => {
loggingFunction('Subscribing for the push notifications');
OneSignal.User.PushSubscription.optIn();
OneSignal.User.pushSubscription.optIn();
});

const optOutButton = renderButtonView('Opt Out', () => {
loggingFunction('Unsubscribing from the push notifications');
OneSignal.User.PushSubscription.optOut();
OneSignal.User.pushSubscription.optOut();
});

return [
Expand Down
2 changes: 1 addition & 1 deletion examples/RNOneSignalTS/src/OSDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class OSDemo extends React.Component<Props, State> {
this.OSLog('OneSignal: did dismiss IAM: ', event);
});

OneSignal.User.PushSubscription.addEventListener(
OneSignal.User.pushSubscription.addEventListener(
'change',
(subscription) => {
this.OSLog('OneSignal: subscription changed:', subscription);
Expand Down
2 changes: 1 addition & 1 deletion react-native-onesignal.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Pod::Spec.new do |s|
# pod 'React', :path => '../node_modules/react-native/'

# The Native OneSignal-iOS-SDK XCFramework from cocoapods.
s.dependency 'OneSignalXCFramework', '5.0.0-beta-06'
s.dependency 'OneSignalXCFramework', '5.0.1'
end
20 changes: 10 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export enum LogLevel {
let notificationPermission = false;

// Internal wrapper push subscription state that is being updated by the subscription change handler.
let pushSubscription: PushSubscriptionState = {
let pushSub: PushSubscriptionState = {
id: '',
token: '',
optedIn: false,
Expand All @@ -70,16 +70,16 @@ async function _addPermissionObserver() {
}

async function _addPushSubscriptionObserver() {
OneSignal.User.PushSubscription.addEventListener(
OneSignal.User.pushSubscription.addEventListener(
'change',
(subscriptionChange) => {
pushSubscription = subscriptionChange.current;
pushSub = subscriptionChange.current;
},
);

pushSubscription.id = await RNOneSignal.getPushSubscriptionId();
pushSubscription.token = await RNOneSignal.getPushSubscriptionToken();
pushSubscription.optedIn = await RNOneSignal.getOptedIn();
pushSub.id = await RNOneSignal.getPushSubscriptionId();
pushSub.token = await RNOneSignal.getPushSubscriptionToken();
pushSub.optedIn = await RNOneSignal.getOptedIn();
}

export namespace OneSignal {
Expand Down Expand Up @@ -192,7 +192,7 @@ export namespace OneSignal {
}

export namespace User {
export namespace PushSubscription {
export namespace pushSubscription {
/** Add a callback that fires when the OneSignal subscription state changes. */
export function addEventListener(
event: 'change',
Expand Down Expand Up @@ -224,7 +224,7 @@ export namespace OneSignal {
return '';
}

return pushSubscription.id;
return pushSub.id;
}

/** The readonly push subscription token */
Expand All @@ -233,7 +233,7 @@ export namespace OneSignal {
return '';
}

return pushSubscription.token;
return pushSub.token;
}

/**
Expand All @@ -247,7 +247,7 @@ export namespace OneSignal {
return false;
}

return pushSubscription.optedIn;
return pushSub.optedIn;
}

/** Enable the push notification subscription to OneSignal. */
Expand Down

0 comments on commit 3472b8b

Please sign in to comment.