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
3 changes: 2 additions & 1 deletion examples/demo/src/hooks/useOneSignal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,9 @@ export function useOneSignal(): UseOneSignalReturn {

void load().catch((err) => {
if (cancelled) return;
console.error(`Initial load error: ${String(err)}`);
log.error(`Initial load error: ${String(err)}`);
setIsLoading(false);
setIsReady(true);
});

return () => {
Expand Down
3 changes: 3 additions & 0 deletions examples/demo_pods/android/capacitor.settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/
include ':capacitor-keyboard'
project(':capacitor-keyboard').projectDir = new File('../node_modules/@capacitor/keyboard/android')

include ':capacitor-splash-screen'
project(':capacitor-splash-screen').projectDir = new File('../node_modules/@capacitor/splash-screen/android')

include ':capacitor-status-bar'
project(':capacitor-status-bar').projectDir = new File('../node_modules/@capacitor/status-bar/android')

Expand Down
8 changes: 8 additions & 0 deletions examples/demo_pods/capacitor.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ const config: CapacitorConfig = {
appId: 'com.onesignal.sdkdemo',
appName: 'OneSignal Demo',
webDir: 'dist',
loggingBehavior: 'debug',
ios: {
// Documented OneSignal setup. Otherwise Capacitor's NotificationRouter
// becomes the notification delegate and suppresses foreground display.
handleApplicationNotifications: false,
// Force WKWebView.isInspectable = true so Appium's XCUITest driver can
// enumerate the WebView context in Release builds on iOS 16.4+. Without
Expand All @@ -15,7 +18,12 @@ const config: CapacitorConfig = {
},
plugins: {
SplashScreen: {
launchShowDuration: 2000,
// Hide the splash manually so we can ensure native permission dialogs
// (e.g. push on Android 13+) don't appear behind/over the splash.
launchAutoHide: false,
backgroundColor: '#ffffff',
showSpinner: false,
},
},
};
Expand Down
1 change: 1 addition & 0 deletions examples/demo_pods/ios/App/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def capacitor_pods
pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorKeyboard', :path => '../../node_modules/@capacitor/keyboard'
pod 'CapacitorSplashScreen', :path => '../../node_modules/@capacitor/splash-screen'
pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar'
pod 'OnesignalCapacitorPlugin', :path => '../../node_modules/@onesignal/capacitor-plugin'
end
Expand Down
1 change: 1 addition & 0 deletions examples/demo_pods/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@capacitor/core": "^8.5.0",
"@capacitor/ios": "^8.5.0",
"@capacitor/keyboard": "^8.0.2",
"@capacitor/splash-screen": "^8.0.1",
"@capacitor/status-bar": "^8.0.2",
"@ionic/react": "^8.8.3",
"@ionic/react-router": "^8.8.3",
Expand Down
11 changes: 11 additions & 0 deletions examples/demo_pods/src/components/ButtonGrid.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { FC, ReactNode } from 'react';

interface ButtonGridProps {
children: ReactNode;
}

const ButtonGrid: FC<ButtonGridProps> = ({ children }) => (
<div className="button-grid">{children}</div>
);

export default ButtonGrid;
55 changes: 55 additions & 0 deletions examples/demo_pods/src/components/LogView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { useEffect, useRef, useState, type FC } from 'react';
import { MdDelete, MdExpandLess, MdExpandMore } from 'react-icons/md';

import { clearLogs, useLogs } from '../services/LogService';

const LogView: FC = () => {
const logs = useLogs();
const listRef = useRef<HTMLDivElement>(null);
const [collapsed, setCollapsed] = useState(false);

useEffect(() => {
const list = listRef.current;
if (list) list.scrollTop = list.scrollHeight;
}, [logs, collapsed]);

return (
<section className="log-view" data-testid="log_view">
<div className="log-head">
<span>LOGS ({logs.length})</span>
<div className="log-actions">
<button
type="button"
className="log-clear"
onClick={clearLogs}
aria-label="Clear logs"
data-testid="log_clear_button"
>
<MdDelete />
</button>
<button
type="button"
onClick={() => setCollapsed((value) => !value)}
aria-label={collapsed ? 'Expand logs' : 'Collapse logs'}
data-testid="log_toggle_button"
>
{collapsed ? <MdExpandMore /> : <MdExpandLess />}
</button>
</div>
</div>
<div className="log-list" ref={listRef} hidden={collapsed}>
{logs.length === 0 ? (
<div className="log-empty">No logs yet</div>
) : (
logs.map((entry, index) => (
<div key={entry.id} className="log-entry" data-testid={`log_entry_${index}`}>
<span className="log-time">{entry.time}</span> {entry.message}
</div>
))
)}
</div>
</section>
);
};

export default LogView;
23 changes: 13 additions & 10 deletions examples/demo_pods/src/components/sections/AliasesSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { FC } from 'react';
import { useMemo, useState } from 'react';

import ActionButton from '../ActionButton';
import ButtonGrid from '../ButtonGrid';
import { PairList } from '../ListWidgets';
import MultiPairInputModal from '../modals/MultiPairInputModal';
import PairInputModal from '../modals/PairInputModal';
Expand Down Expand Up @@ -38,16 +39,18 @@ const AliasesSection: FC<AliasesSectionProps> = ({
return (
<SectionCard title="ALIASES" sectionKey="aliases" onInfoTap={onInfoTap}>
<PairList items={items} emptyText="No aliases added" loading={loading} sectionKey="aliases" />
<ActionButton type="button" onClick={() => setAddOpen(true)} data-testid="add_alias_button">
ADD ALIAS
</ActionButton>
<ActionButton
type="button"
onClick={() => setAddMultipleOpen(true)}
data-testid="add_multiple_aliases_button"
>
ADD MULTIPLE ALIASES
</ActionButton>
<ButtonGrid>
<ActionButton type="button" onClick={() => setAddOpen(true)} data-testid="add_alias_button">
ADD ALIAS
</ActionButton>
<ActionButton
type="button"
onClick={() => setAddMultipleOpen(true)}
data-testid="add_multiple_aliases_button"
>
ADD ALIASES
</ActionButton>
</ButtonGrid>
<PairInputModal
open={addOpen}
title="Add Alias"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { FC } from 'react';
import { useState } from 'react';

import ActionButton from '../ActionButton';
import ButtonGrid from '../ButtonGrid';
import SectionCard from '../SectionCard';

const ORDER_STATUSES = [
Expand Down Expand Up @@ -101,31 +102,33 @@ const LiveActivitySection: FC<LiveActivitySectionProps> = ({
/>
</div>
</div>
<ActionButton
type="button"
disabled={!activityId.trim()}
onClick={handleStart}
data-testid="start_live_activity_button"
>
START LIVE ACTIVITY
</ActionButton>
<ActionButton
type="button"
disabled={!activityId.trim() || updating || !hasApiKey}
onClick={handleUpdate}
data-testid="update_live_activity_button"
>
{`UPDATE → ${nextStatus.status.replaceAll('_', ' ').toUpperCase()}`}
</ActionButton>
<ActionButton
variant="outline"
type="button"
disabled={!activityId.trim() || !hasApiKey}
onClick={() => onEnd(activityId)}
data-testid="end_live_activity_button"
>
END LIVE ACTIVITY
</ActionButton>
<ButtonGrid>
<ActionButton
type="button"
disabled={!activityId.trim()}
onClick={handleStart}
data-testid="start_live_activity_button"
>
START ACTIVITY
</ActionButton>
<ActionButton
type="button"
disabled={!activityId.trim() || updating || !hasApiKey}
onClick={handleUpdate}
data-testid="update_live_activity_button"
>
{`UPDATE → ${nextStatus.status.replaceAll('_', ' ').toUpperCase()}`}
</ActionButton>
<ActionButton
variant="outline"
type="button"
disabled={!activityId.trim() || !hasApiKey}
onClick={() => onEnd(activityId)}
data-testid="end_live_activity_button"
>
END ACTIVITY
</ActionButton>
</ButtonGrid>
{!hasApiKey && (
<p className="hint-text">Set VITE_ONESIGNAL_API_KEY in .env to enable update &amp; end</p>
)}
Expand Down
23 changes: 13 additions & 10 deletions examples/demo_pods/src/components/sections/LocationSection.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { FC } from 'react';

import ActionButton from '../ActionButton';
import ButtonGrid from '../ButtonGrid';
import SectionCard from '../SectionCard';
import { useSnackbar } from '../ToastProvider';
import ToggleRow from '../ToggleRow';
Expand Down Expand Up @@ -36,16 +37,18 @@ const LocationSection: FC<LocationSectionProps> = ({
onToggle={onToggleLocationShared}
testId="location_shared_toggle"
/>
<ActionButton type="button" onClick={onPromptLocation} data-testid="prompt_location_button">
PROMPT LOCATION
</ActionButton>
<ActionButton
type="button"
onClick={() => void handleCheckLocation()}
data-testid="check_location_button"
>
CHECK LOCATION SHARED
</ActionButton>
<ButtonGrid>
<ActionButton type="button" onClick={onPromptLocation} data-testid="prompt_location_button">
PROMPT LOCATION
</ActionButton>
<ActionButton
type="button"
onClick={() => void handleCheckLocation()}
data-testid="check_location_button"
>
CHECK LOCATION
</ActionButton>
</ButtonGrid>
</SectionCard>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { FC } from 'react';

import ActionButton from '../ActionButton';
import ButtonGrid from '../ButtonGrid';
import SectionCard from '../SectionCard';

interface SendIamSectionProps {
Expand All @@ -21,7 +22,7 @@ const iamButtons: { label: string; type: string }[] = [

const SendIamSection: FC<SendIamSectionProps> = ({ onInfoTap, onSendIam }) => (
<SectionCard title="SEND IN-APP MESSAGE" sectionKey="send_iam" onInfoTap={onInfoTap}>
<div className="iam-grid">
<ButtonGrid>
{iamButtons.map((btn) => (
<ActionButton
key={btn.type}
Expand All @@ -32,7 +33,7 @@ const SendIamSection: FC<SendIamSectionProps> = ({ onInfoTap, onSendIam }) => (
{btn.label}
</ActionButton>
))}
</div>
</ButtonGrid>
</SectionCard>
);

Expand Down
51 changes: 27 additions & 24 deletions examples/demo_pods/src/components/sections/SendPushSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { FC } from 'react';
import { useState } from 'react';

import ActionButton from '../ActionButton';
import ButtonGrid from '../ButtonGrid';
import CustomNotificationModal from '../modals/CustomNotificationModal';
import SectionCard from '../SectionCard';

Expand Down Expand Up @@ -31,30 +32,32 @@ const SendPushSection: FC<SendPushSectionProps> = ({

return (
<SectionCard title="SEND PUSH NOTIFICATION" sectionKey="send_push" onInfoTap={onInfoTap}>
<ActionButton type="button" onClick={onSendSimple} data-testid="send_simple_button">
SIMPLE
</ActionButton>
<ActionButton type="button" onClick={onSendImage} data-testid="send_image_button">
WITH IMAGE
</ActionButton>
<ActionButton type="button" onClick={onSendSound} data-testid="send_sound_button">
WITH SOUND
</ActionButton>
<ActionButton
type="button"
onClick={() => setCustomOpen(true)}
data-testid="send_custom_button"
>
CUSTOM
</ActionButton>
<ActionButton
variant="outline"
type="button"
onClick={onClearAll}
data-testid="clear_all_button"
>
CLEAR ALL
</ActionButton>
<ButtonGrid>
<ActionButton type="button" onClick={onSendSimple} data-testid="send_simple_button">
SIMPLE
</ActionButton>
<ActionButton type="button" onClick={onSendImage} data-testid="send_image_button">
WITH IMAGE
</ActionButton>
<ActionButton type="button" onClick={onSendSound} data-testid="send_sound_button">
WITH SOUND
</ActionButton>
<ActionButton
type="button"
onClick={() => setCustomOpen(true)}
data-testid="send_custom_button"
>
CUSTOM
</ActionButton>
<ActionButton
variant="outline"
type="button"
onClick={onClearAll}
data-testid="clear_all_button"
>
CLEAR ALL
</ActionButton>
</ButtonGrid>
<CustomNotificationModal
open={customOpen}
onClose={() => setCustomOpen(false)}
Expand Down
Loading
Loading