Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/demo/bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions examples/demo/src/components/ActionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AppColors, AppSpacing } from '../theme';
interface Props {
label: string;
onPress: () => void;
variant?: 'primary' | 'destructive' | 'outlined';
variant?: 'primary' | 'outlined';
disabled?: boolean;
loading?: boolean;
testID?: string;
Expand All @@ -29,12 +29,9 @@ export default function ActionButton({
const bgColor = variant === 'primary' ? AppColors.osPrimary : 'transparent';

const borderStyle =
variant === 'outlined' || variant === 'destructive'
? { borderWidth: 1, borderColor: AppColors.osPrimary }
: {};
variant === 'outlined' ? { borderWidth: 1, borderColor: AppColors.osPrimary } : {};

const textColor =
variant === 'outlined' || variant === 'destructive' ? AppColors.osPrimary : AppColors.white;
const textColor = variant === 'outlined' ? AppColors.osPrimary : AppColors.white;

return (
<TouchableOpacity
Expand Down
19 changes: 2 additions & 17 deletions examples/demo/src/components/sections/LiveActivitySection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,10 @@ interface Props {
onStart: (activityId: string, attributes: object, content: object) => void;
onUpdate: (activityId: string, eventUpdates: Record<string, unknown>) => Promise<void>;
onEnd: (activityId: string) => Promise<void>;
onStopUpdating: (activityId: string) => void;
onInfoTap?: () => void;
}

export default function LiveActivitySection({
onStart,
onUpdate,
onEnd,
onStopUpdating,
onInfoTap,
}: Props) {
export default function LiveActivitySection({ onStart, onUpdate, onEnd, onInfoTap }: Props) {
const [activityId, setActivityId] = useState('order-1');
const [orderNumber, setOrderNumber] = useState('ORD-1234');
const [statusIndex, setStatusIndex] = useState(0);
Expand Down Expand Up @@ -97,20 +90,12 @@ export default function LiveActivitySection({
testID="update_live_activity_button"
/>

<ActionButton
label="STOP UPDATING LIVE ACTIVITY"
onPress={() => onStopUpdating(activityId)}
disabled={!activityId.trim()}
variant="outlined"
testID="stop_updating_live_activity_button"
/>

{/* Requires API key */}
<ActionButton
label="END LIVE ACTIVITY"
onPress={() => onEnd(activityId)}
disabled={!activityId.trim()}
variant="destructive"
variant="outlined"
testID="end_live_activity_button"
/>
</View>
Expand Down
9 changes: 0 additions & 9 deletions examples/demo/src/context/AppContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ type AppContextValue = {
startDefaultLiveActivity: (activityId: string, attributes: object, content: object) => void;
updateLiveActivity: (activityId: string, eventUpdates: Record<string, unknown>) => Promise<void>;
endLiveActivity: (activityId: string) => Promise<void>;
stopUpdatingLiveActivity: (activityId: string) => void;
};

const AppContext = createContext<AppContextValue | null>(null);
Expand Down Expand Up @@ -715,12 +714,6 @@ export function AppContextProvider({ children }: Props) {
Toast.show({ type: success ? 'info' : 'error', text1: msg });
}, []);

const stopUpdatingLiveActivity = useCallback((activityId: string) => {
repository.exitLiveActivity(activityId);
log.i(TAG, `Exited Live Activity: ${activityId}`);
Toast.show({ type: 'info', text1: `Exited Live Activity: ${activityId}` });
}, []);

const contextValue = useMemo<AppContextValue>(
() => ({
state,
Expand Down Expand Up @@ -757,7 +750,6 @@ export function AppContextProvider({ children }: Props) {
startDefaultLiveActivity: startDefaultLiveActivity,
updateLiveActivity,
endLiveActivity,
stopUpdatingLiveActivity,
}),
[
state,
Expand Down Expand Up @@ -794,7 +786,6 @@ export function AppContextProvider({ children }: Props) {
startDefaultLiveActivity,
updateLiveActivity,
endLiveActivity,
stopUpdatingLiveActivity,
],
);

Expand Down
4 changes: 0 additions & 4 deletions examples/demo/src/repositories/OneSignalRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,6 @@ class OneSignalRepository {
): Promise<boolean> {
return this.apiService.updateLiveActivity(activityId, event, eventUpdates);
}

exitLiveActivity(activityId: string): void {
OneSignal.LiveActivities.exit(activityId);
}
}

export default OneSignalRepository;
1 change: 0 additions & 1 deletion examples/demo/src/screens/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ export default function HomeScreen() {
onStart={app.startDefaultLiveActivity}
onUpdate={app.updateLiveActivity}
onEnd={app.endLiveActivity}
onStopUpdating={app.stopUpdatingLiveActivity}
onInfoTap={() => showTooltipModal('liveActivities')}
/>
)}
Expand Down
3 changes: 3 additions & 0 deletions src/NativeOneSignal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export interface Spec extends TurboModule {

// Live Activities (iOS only, stubs on Android)
enterLiveActivity(activityId: string, token: string, callback: (result: Object) => void): void;

/** @deprecated Currently unsupported, avoid using this method. */
exitLiveActivity(activityId: string, callback: (result: Object) => void): void;

setPushToStartToken(activityType: string, token: string): void;
removePushToStartToken(activityType: string): void;
setupDefaultLiveActivity(options: Object | null): void;
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export namespace OneSignal {
*
* Only applies to iOS
*
* @deprecated Currently unsupported, avoid using this method.
* @param activityId: The activity identifier the live activity on this device will no longer receive updates for.
**/
export function exit(activityId: string, handler: (result: object) => void = () => {}) {
Expand Down
Loading