Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛LaunchData is being ignored #1

Open
1 task done
grahamyesfit opened this issue Dec 16, 2023 · 1 comment
Open
1 task done

🐛LaunchData is being ignored #1

grahamyesfit opened this issue Dec 16, 2023 · 1 comment

Comments

@grahamyesfit
Copy link

What were you trying to do?

I have created a Lens using Snapchat's dynamic lens example as a starting point.

I tested the Lens in Lens Studio with a fallback datasource and the Lens was correctly showing the values.

I published the Lens and I'm viewing it in our App.

Reproduceable Code

//JavaScript code 

	const initialLaunchData = { 
		challenge: 'Return to Oz',
		duration: '... in 13 Days', 
		stats: ["22 Workouts", "13K calories burned", "30 miles"], 
		date: [2023, 12, 14]  
	};

    return (
        <>
            <CameraKit
                ref={ref}
                style={styles.container}
                isActive={active}
                initialCameraFacing="front"
                initialLens={{
                    id: route?.params?.lensId,
                    launchData: initialLaunchData,
                }}
                zoom={zoom}
                focus={focus}
                preset="hd-1280x720"
                lensGroups={[cameraKitSettings.lensGroupId]}
                onInitialized={() => {
                    console.log('onInitialized');
                }}
                onLensChanged={(_event) => {
                    // console.log(event);
                }}
                onPhotoTaken={(picture) => {
                    console.log({ picture });
                    navigation.navigate('SnapchatPreviewScreen', {
                        type: Enums.PREVIEW_TYPES.PHOTO,
                        path: picture.path,
                    });
                }}
                onVideoRecordingFinished={(video) => {
                    console.log({ video });
                    setIsVideoRecording(false);
                    navigation.navigate('SnapchatPreviewScreen', {
                        type: Enums.PREVIEW_TYPES.VIDEO,
                        path: video.path,
                    });
                }}
                onError={(error) => {
                    console.log('onError', error);
                }}
            />
//Lens manager code
//@input Component.Text challengeText;
//@input Component.Text durationText;
//@input Component.Text statsText;
//@input Component.Text dateText;

// This will use FallbackData if global.launchParams has not been filled out 
var launchParams = global.launchParams;

/* Storage accessors */
var challenge;
var duration;
var stats;
var date;  

var storageKeys = ["challenge","duration","stats", "date"]

/****************/
function getData() {
    if (launchParams) {
        if (launchParams.has(storageKeys[0]) &&
            launchParams.has(storageKeys[1]) &&
            launchParams.has(storageKeys[2]) &&
            launchParams.has(storageKeys[3])) {
            
            challenge = launchParams.getString(storageKeys[0]);
            duration = launchParams.getString(storageKeys[1]);
            stats = launchParams.getString(storageKeys[2]);
            date = launchParams.getStringArray(storageKeys[3]);
            return true;
        }
        
    return false;
    }
}

function populateFields() {
    
    script.challengeText.text = challenge;
    script.durationText.text = duration;
    
    for(var i in stats) {
        script.statsText.text += (parseInt(i) + 1) + ". " +stats[i] + '\n';
    }
    
    setDate();
}

function setDate() {
    
    if(date.length == 3 && date[1] <= 12) {
        script.dateText.text = global.localizationSystem.getDateFormatted(new Date(date[0], date[1] -1, date[2]));      
    } else {
        print("Error: Incorrect date passed in, should be [year, month, day]. Today's date will be used instead");
        script.dateText.text = global.localizationSystem.getDateFormatted(new Date());
    }
    
}


if(getData()) { 
    populateFields();
} else {
    print("Failed to get Data");

What happened instead?

The correct Lens is shown but the hardcoded values for the fields are shown, not the launchData values that were passed in.

Relevant log output

No response

Device

Pixel 7

Library Version

0.2.0

Additional information

@ridvanaltun
Copy link
Member

Hello @grahamyesfit,

I was the sole contributor to this repository. Unfortunately, due to a company layoff, I have left. As a result, there is no one maintaining this library anymore.

Nevertheless, I intend to address this issue at the appropriate time. It appears to be a straightforward problem to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants